Skip to content

Commit 27b3451

Browse files
committed
windows: simplify Inno setup defn and reduce payload size
To keep the size of the Windows distribution small, directly target the Win32 Avalonia packages rather than the Desktop package that includes macOS and Linux dependencies.
1 parent cb7434b commit 27b3451

File tree

5 files changed

+45
-34
lines changed

5 files changed

+45
-34
lines changed

src/shared/Core/Core.csproj

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
<Reference Include="System.Net.Http" />
1515
<Reference Include="System.Web" />
1616
<PackageReference Include="Microsoft.Identity.Client.Broker" Version="4.52.0" />
17+
<PackageReference Include="Avalonia.Win32" Version="11.0.0-preview6"/>
18+
</ItemGroup>
19+
20+
<ItemGroup Condition="'$(TargetFramework)' != 'net472'">
21+
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview6" />
1722
</ItemGroup>
1823

1924
<ItemGroup>
@@ -22,7 +27,7 @@
2227
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" Version="2.28.0" />
2328
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.21216.1" />
2429
<PackageReference Include="Avalonia" Version="11.0.0-preview6" />
25-
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview6" />
30+
<PackageReference Include="Avalonia.Skia" Version="11.0.0-preview6" />
2631
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0-preview6" />
2732
</ItemGroup>
2833

src/shared/Core/UI/AvaloniaUi.cs

+5
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ public static Task ShowWindowAsync(Func<Window> windowFunc, object dataContext,
4747
Dispatcher.MainThread.Post(appCancelToken =>
4848
{
4949
AppBuilder.Configure<AvaloniaApp>()
50+
#if NETFRAMEWORK
51+
.UseWin32()
52+
.UseSkia()
53+
#else
5054
.UsePlatformDetect()
55+
#endif
5156
.LogToTrace()
5257
// Workaround https://github.com/AvaloniaUI/Avalonia/issues/10296
5358
// by always setting a application lifetime.

src/shared/Git-Credential-Manager/Program.cs

+5
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,12 @@ private static void AppMain(object o)
106106
// Required for Avalonia designer
107107
static AppBuilder BuildAvaloniaApp() =>
108108
AppBuilder.Configure<AvaloniaApp>()
109+
#if NETFRAMEWORK
110+
.UseWin32()
111+
.UseSkia()
112+
#else
109113
.UsePlatformDetect()
114+
#endif
110115
.LogToTrace();
111116
}
112117
}

src/windows/Installer.Windows/Setup.iss

+1-33
Original file line numberDiff line numberDiff line change
@@ -103,39 +103,7 @@ Filename: "{app}\{#GcmExe}"; Parameters: "configure {#GcmConfigureCmdArgs}"; Fla
103103
Filename: "{app}\{#GcmExe}"; Parameters: "unconfigure {#GcmConfigureCmdArgs}"; Flags: runhidden
104104

105105
[Files]
106-
Source: "{#PayloadDir}\Atlassian.Bitbucket.dll"; DestDir: "{app}"; Flags: ignoreversion
107-
Source: "{#PayloadDir}\Atlassian.Bitbucket.UI.exe"; DestDir: "{app}"; Flags: ignoreversion
108-
Source: "{#PayloadDir}\Atlassian.Bitbucket.UI.exe.config"; DestDir: "{app}"; Flags: ignoreversion
109-
Source: "{#PayloadDir}\git-credential-manager.exe"; DestDir: "{app}"; Flags: ignoreversion
110-
Source: "{#PayloadDir}\git-credential-manager.exe.config"; DestDir: "{app}"; Flags: ignoreversion
111-
Source: "{#PayloadDir}\git-credential-manager-core.exe"; DestDir: "{app}"; Flags: ignoreversion
112-
Source: "{#PayloadDir}\git-credential-manager-core.exe.config"; DestDir: "{app}"; Flags: ignoreversion
113-
Source: "{#PayloadDir}\git-credential-manager-ui.exe"; DestDir: "{app}"; Flags: ignoreversion
114-
Source: "{#PayloadDir}\git-credential-manager-ui.exe.config"; DestDir: "{app}"; Flags: ignoreversion
115-
Source: "{#PayloadDir}\GitHub.dll"; DestDir: "{app}"; Flags: ignoreversion
116-
Source: "{#PayloadDir}\GitHub.UI.exe"; DestDir: "{app}"; Flags: ignoreversion
117-
Source: "{#PayloadDir}\GitHub.UI.exe.config"; DestDir: "{app}"; Flags: ignoreversion
118-
Source: "{#PayloadDir}\GitHub.UI.Shared.dll"; DestDir: "{app}"; Flags: ignoreversion
119-
Source: "{#PayloadDir}\GitLab.dll"; DestDir: "{app}"; Flags: ignoreversion
120-
Source: "{#PayloadDir}\GitLab.UI.exe"; DestDir: "{app}"; Flags: ignoreversion
121-
Source: "{#PayloadDir}\GitLab.UI.exe.config"; DestDir: "{app}"; Flags: ignoreversion
122-
Source: "{#PayloadDir}\GitLab.UI.Shared.dll"; DestDir: "{app}"; Flags: ignoreversion
123-
Source: "{#PayloadDir}\Microsoft.AzureRepos.dll"; DestDir: "{app}"; Flags: ignoreversion
124-
Source: "{#PayloadDir}\gcmcore.dll"; DestDir: "{app}"; Flags: ignoreversion
125-
Source: "{#PayloadDir}\gcmcoreuiwpf.dll"; DestDir: "{app}"; Flags: ignoreversion
126-
Source: "{#PayloadDir}\Microsoft.Identity.Client.Broker.dll"; DestDir: "{app}"; Flags: ignoreversion
127-
Source: "{#PayloadDir}\Microsoft.Identity.Client.dll"; DestDir: "{app}"; Flags: ignoreversion
128-
Source: "{#PayloadDir}\Microsoft.Identity.Client.Extensions.Msal.dll"; DestDir: "{app}"; Flags: ignoreversion
129-
Source: "{#PayloadDir}\Microsoft.Identity.Client.NativeInterop.dll"; DestDir: "{app}"; Flags: ignoreversion
130-
Source: "{#PayloadDir}\Microsoft.IdentityModel.Abstractions.dll"; DestDir: "{app}"; Flags: ignoreversion
131-
Source: "{#PayloadDir}\msalruntime_x86.dll"; DestDir: "{app}"; Flags: ignoreversion
132-
Source: "{#PayloadDir}\Newtonsoft.Json.dll"; DestDir: "{app}"; Flags: ignoreversion
133-
Source: "{#PayloadDir}\NOTICE"; DestDir: "{app}"; Flags: ignoreversion
134-
Source: "{#PayloadDir}\System.Buffers.dll"; DestDir: "{app}"; Flags: ignoreversion
135-
Source: "{#PayloadDir}\System.CommandLine.dll"; DestDir: "{app}"; Flags: ignoreversion
136-
Source: "{#PayloadDir}\System.Memory.dll"; DestDir: "{app}"; Flags: ignoreversion
137-
Source: "{#PayloadDir}\System.Numerics.Vectors.dll"; DestDir: "{app}"; Flags: ignoreversion
138-
Source: "{#PayloadDir}\System.Runtime.CompilerServices.Unsafe.dll"; DestDir: "{app}"; Flags: ignoreversion
106+
Source: "{#PayloadDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs
139107

140108
[Code]
141109
// Don't allow installing conflicting architectures

src/windows/Installer.Windows/layout.ps1

+28
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,34 @@ Copy-Item -Path "$PAYLOAD/git-credential-manager.exe" `
7373
Copy-Item -Path "$PAYLOAD/git-credential-manager.exe.config" `
7474
-Destination "$PAYLOAD/git-credential-manager-core.exe.config"
7575

76+
# Delete libraries that are not needed for Windows but find their way
77+
# into the publish output.
78+
Remove-Item -Path "$PAYLOAD/*.dylib" -Force
79+
80+
# Delete extraneous files that get included for other architectures
81+
# We only care about x86 as the core GCM executable is only targeting x86
82+
Remove-Item -Path "$PAYLOAD/arm/" -Recurse -Force
83+
Remove-Item -Path "$PAYLOAD/arm64/" -Recurse -Force
84+
Remove-Item -Path "$PAYLOAD/x64/" -Recurse -Force
85+
Remove-Item -Path "$PAYLOAD/musl-x64/" -Recurse -Force
86+
Remove-Item -Path "$PAYLOAD/runtimes/win-arm64/" -Recurse -Force
87+
Remove-Item -Path "$PAYLOAD/runtimes/win-x64/" -Recurse -Force
88+
89+
# The Avalonia and MSAL binaries in these directories are already included in
90+
# the $PAYLOAD directory directly, so we can delete these extra copies.
91+
Remove-Item -Path "$PAYLOAD/x86/libSkiaSharp.dll" -Recurse -Force
92+
Remove-Item -Path "$PAYLOAD/x86/libHarfBuzzSharp.dll" -Recurse -Force
93+
Remove-Item -Path "$PAYLOAD/runtimes/win-x86/native/msalruntime_x86.dll" -Recurse -Force
94+
95+
# Delete localized resource assemblies - we don't localize the core GCM assembly anyway
96+
Get-ChildItem "$PAYLOAD" -Recurse -Include "*.resources.dll" | Remove-Item -Force
97+
98+
# Delete any empty directories
99+
Get-ChildItem "$PAYLOAD" -Recurse -Directory `
100+
| Sort-Object -Property FullName -Descending `
101+
| Where-Object { ! (Get-ChildItem $_.FullName -File -Recurse).Count } `
102+
| Remove-Item -Force
103+
76104
# Collect symbols
77105
Write-Output "Collecting managed symbols..."
78106
Move-Item -Path "$PAYLOAD/*.pdb" -Destination "$SYMBOLS"

0 commit comments

Comments
 (0)