Skip to content

Commit

Permalink
build: add MSAL single file publish workaround
Browse files Browse the repository at this point in the history
Add a workaround for a bug in MSAL's loading of native dependencies when
published as a single file bundle.

Using the IncludeAddContentForSelfExtract option will cause all managed
and native dependencies to be extracted on first launch to a temporary
directory, and executed from there.

This only affects Windows as only Windows has support for the MSAL
runtime that requires the native dependencies.
  • Loading branch information
mjcheetham committed Sep 22, 2023
1 parent 9556574 commit 5bad1be
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/shared/Git-Credential-Manager/Git-Credential-Manager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,33 @@
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>

<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('win-'))">
<!--
Workaround a bug in MSAL when publishing as a single file on Windows.
The Microsoft.Identity.Client.NativeInterop.dll assembly is not able to
locate the native libraries when published as a single file and crashes.
This is due to the use of an unsupported API (Assembly::CodeBase).
Using the IncludeAllContentForSelfExtract property will cause the single
file to be extracted to a temporary directory and executed from there
(including all native and managed assemblies).
<ISSUE>
-->
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>

<!--
Prefer to reduce the size of the single file by compressing the containing
assemblies. This will increase the startup time of the application, but
since we're using the IncludeAllContentForSelfExtract property onWindows,
the cost of decompressing the assemblies is only paid on the first launch.
Keeping the assembly size small is important because we are bundled inside
of Git for Windows and we don't want to bloat their distribution.
-->
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Atlassian.Bitbucket\Atlassian.Bitbucket.csproj" />
<ProjectReference Include="..\GitHub\GitHub.csproj" />
Expand Down

0 comments on commit 5bad1be

Please sign in to comment.