Skip to content

Commit a958838

Browse files
committed
build: add MSAL single file publish workaround
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.
1 parent 79a96fb commit a958838

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/shared/Git-Credential-Manager/Git-Credential-Manager.csproj

+27
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,33 @@
1515
<InvariantGlobalization>true</InvariantGlobalization>
1616
</PropertyGroup>
1717

18+
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('win-'))">
19+
<!--
20+
Workaround a bug in MSAL when publishing as a single file on Windows.
21+
22+
The Microsoft.Identity.Client.NativeInterop.dll assembly is not able to
23+
locate the native libraries when published as a single file and crashes.
24+
This is due to the use of an unsupported API (Assembly::CodeBase).
25+
26+
Using the IncludeAllContentForSelfExtract property will cause the single
27+
file to be extracted to a temporary directory and executed from there
28+
(including all native and managed assemblies).
29+
30+
<ISSUE>
31+
-->
32+
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
33+
34+
<!--
35+
Prefer to reduce the size of the single file by compressing the containing
36+
assemblies. This will increase the startup time of the application, but
37+
since we're using the IncludeAllContentForSelfExtract property onWindows,
38+
the cost of decompressing the assemblies is only paid on the first launch.
39+
Keeping the assembly size small is important because we are bundled inside
40+
of Git for Windows and we don't want to bloat their distribution.
41+
-->
42+
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
43+
</PropertyGroup>
44+
1845
<ItemGroup>
1946
<ProjectReference Include="..\Atlassian.Bitbucket\Atlassian.Bitbucket.csproj" />
2047
<ProjectReference Include="..\GitHub\GitHub.csproj" />

0 commit comments

Comments
 (0)