Skip to content

Commit b6e98bc

Browse files
committed
Add support for Windows x64 and arm64 builds
1 parent 1b3f77e commit b6e98bc

File tree

5 files changed

+52
-20
lines changed

5 files changed

+52
-20
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ jobs:
1414
windows:
1515
name: Windows
1616
runs-on: windows-latest
17+
strategy:
18+
matrix:
19+
runtime: [win-x86, win-x64, win-arm64]
1720

1821
steps:
1922
- uses: actions/checkout@v6
@@ -27,24 +30,31 @@ jobs:
2730
run: dotnet restore
2831

2932
- name: Build
30-
run: dotnet build --configuration WindowsRelease
33+
run: |
34+
dotnet build src/windows/Installer.Windows/Installer.Windows.csproj `
35+
--configuration=Release `
36+
--runtime=${{ matrix.runtime }}
3137
3238
- name: Test
39+
# GitHub's hosted runners are x64 so can test x64 and x86, but not arm64
40+
if: matrix.runtime != 'win-arm64'
3341
run: |
34-
dotnet test --verbosity normal --configuration=WindowsRelease
42+
dotnet test --verbosity normal `
43+
--configuration=WindowsRelease `
44+
--runtime=${{ matrix.runtime }}
3545
3646
- name: Prepare artifacts
3747
shell: bash
3848
run: |
3949
mkdir -p artifacts/bin
40-
mv out/windows/Installer.Windows/bin/Release/net472/win-x86 artifacts/bin/
41-
cp out/windows/Installer.Windows/bin/Release/net472/win-x86.sym/* artifacts/bin/win-x86/
42-
mv out/windows/Installer.Windows/bin/Release/net472/gcm*.exe artifacts/
50+
mv out/windows/Installer.Windows/bin/Release/net472/${{ matrix.runtime }}/gcm*.exe artifacts/
51+
mv out/windows/Installer.Windows/bin/Release/net472/${{ matrix.runtime }} artifacts/bin/
52+
cp out/windows/Installer.Windows/bin/Release/net472/${{ matrix.runtime }}.sym/* artifacts/bin/${{ matrix.runtime }}/
4353
4454
- name: Upload artifacts
4555
uses: actions/upload-artifact@v6
4656
with:
47-
name: win-x86
57+
name: ${{ matrix.runtime }}
4858
path: |
4959
artifacts
5060

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFrameworks>net8.0</TargetFrameworks>
66
<TargetFrameworks Condition="'$(OSPlatform)'=='windows'">net472;net8.0</TargetFrameworks>
7-
<RuntimeIdentifiers>win-x86;osx-x64;linux-x64;osx-arm64;linux-arm64;linux-arm</RuntimeIdentifiers>
8-
<PlatformTarget Condition="'$(OSPlatform)'=='windows'">x86</PlatformTarget>
7+
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;osx-x64;linux-x64;osx-arm64;linux-arm64;linux-arm</RuntimeIdentifiers>
98
<AssemblyName>git-credential-manager</AssemblyName>
109
<RootNamespace>GitCredentialManager</RootNamespace>
1110
<ApplicationIcon>$(RepoAssetsPath)gcmicon.ico</ApplicationIcon>

src/windows/Installer.Windows/Installer.Windows.csproj

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<Project>
1+
<Project>
22
<!-- Implicit SDK props import -->
33
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
44

55
<PropertyGroup>
66
<TargetFramework>net472</TargetFramework>
77
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
88
<EnableDefaultItems>false</EnableDefaultItems>
9-
<PayloadPath>$(PlatformOutPath)Installer.Windows\bin\$(Configuration)\net472\win-x86</PayloadPath>
9+
<PayloadPath>$(PlatformOutPath)Installer.Windows\bin\$(Configuration)\net472\$(RuntimeIdentifier)</PayloadPath>
1010
<InnoSetupVersion>6.3.1</InnoSetupVersion>
1111
</PropertyGroup>
1212

@@ -27,12 +27,20 @@
2727

2828
<Target Name="CoreCompile" Condition="'$(OSPlatform)'=='windows'">
2929
<PropertyGroup>
30-
<InnoSetupCommandSystem>"$(NuGetPackageRoot)Tools.InnoSetup\$(InnoSetupVersion)\tools\ISCC.exe" /DPayloadDir="$(PayloadPath)" /DInstallTarget=system "$(RepoSrcPath)\windows\Installer.Windows\Setup.iss" /O"$(OutputPath)"</InnoSetupCommandSystem>
31-
<InnoSetupCommandUser>"$(NuGetPackageRoot)Tools.InnoSetup\$(InnoSetupVersion)\tools\ISCC.exe" /DPayloadDir="$(PayloadPath)" /DInstallTarget=user "$(RepoSrcPath)\windows\Installer.Windows\Setup.iss" /O"$(OutputPath)"</InnoSetupCommandUser>
30+
<InnoSetupCommandSystem>"$(NuGetPackageRoot)Tools.InnoSetup\$(InnoSetupVersion)\tools\ISCC.exe" /DPayloadDir="$(PayloadPath)" /DInstallTarget=system /DGcmRuntimeIdentifier="$(RuntimeIdentifier)" "$(RepoSrcPath)\windows\Installer.Windows\Setup.iss" /O"$(OutputPath)"</InnoSetupCommandSystem>
31+
<InnoSetupCommandUser>"$(NuGetPackageRoot)Tools.InnoSetup\$(InnoSetupVersion)\tools\ISCC.exe" /DPayloadDir="$(PayloadPath)" /DInstallTarget=user /DGcmRuntimeIdentifier="$(RuntimeIdentifier)" "$(RepoSrcPath)\windows\Installer.Windows\Setup.iss" /O"$(OutputPath)"</InnoSetupCommandUser>
3232
</PropertyGroup>
3333

3434
<Message Text="Lay Out" Importance="High" />
35-
<Exec Condition="'$(NoLayout)'!='true'" Command="powershell.exe –NonInteractive –ExecutionPolicy Unrestricted -Command &quot;&amp; {&amp;'$(MSBuildProjectDirectory)\layout.ps1' -Configuration '$(Configuration)' -Output '$(PayloadPath)'}&quot;" />
35+
<Exec Condition="'$(NoLayout)'!='true'"
36+
ConsoleToMSBuild="true"
37+
Command="powershell.exe –NonInteractive –ExecutionPolicy Unrestricted -Command &quot;&amp; {&amp;'$(MSBuildProjectDirectory)\layout.ps1' -Configuration '$(Configuration)' -Output '$(PayloadPath)' -RuntimeIdentifier '$(RuntimeIdentifier)'; if ($?) { exit 0 } else { exit 1 }}&quot;"
38+
IgnoreExitCode="true">
39+
<!-- If we want to display the console output if the exit code is not 0, we need to capture it and then output it using the <Error /> below -->
40+
<Output TaskParameter="ExitCode" PropertyName="ExitCodeOfExec" />
41+
<Output TaskParameter="ConsoleOutput" PropertyName="OutputOfExec" />
42+
</Exec>
43+
<Error Condition="'$(NoLayout)'!='true' AND '$(ExitCodeOfExec)' != '0'" Text="Layout script failed with exit code $(ExitCodeOfExec) and message $(OutputOfExec)" />
3644
<Message Text="$(InnoSetupCommandSystem)" Importance="High" />
3745
<Exec Command="$(InnoSetupCommandSystem)" />
3846
<Message Text="$(InnoSetupCommandUser)" Importance="High" />

src/windows/Installer.Windows/Setup.iss

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
#error Installer target property 'InstallTarget' must be specifed
1616
#endif
1717

18+
#ifndef GcmRuntimeIdentifier
19+
#error GCM Runtime Identifier 'GcmRuntimeIdentifier' must be specifed (e.g. win-x64)
20+
#endif
21+
1822
#if InstallTarget == "user"
1923
#define GcmAppId "{{aa76d31d-432c-42ee-844c-bc0bc801cef3}}"
2024
#define GcmLongName "Git Credential Manager (User)"
@@ -40,7 +44,6 @@
4044
#define GcmRepoRoot "..\..\.."
4145
#define GcmAssets GcmRepoRoot + "\assets"
4246
#define GcmExe "git-credential-manager.exe"
43-
#define GcmArch "x86"
4447

4548
#ifnexist PayloadDir + "\" + GcmExe
4649
#error Payload files are missing
@@ -67,9 +70,17 @@ AppUpdatesURL={#GcmUrl}
6770
AppContact={#GcmUrl}
6871
AppCopyright={#GcmCopyright}
6972
AppReadmeFile={#GcmReadme}
73+
; Windows ARM64 supports installing and running x64 binaries, but not vice versa.
74+
#if GcmRuntimeIdentifier=="win-x64"
75+
ArchitecturesAllowed=x64compatible
76+
ArchitecturesInstallIn64BitMode=x64compatible
77+
#elif GcmRuntimeIdentifier=="win-arm64"
78+
ArchitecturesAllowed=arm64
79+
ArchitecturesInstallIn64BitMode=arm64
80+
#endif
7081
VersionInfoVersion={#GcmVersion}
7182
LicenseFile={#GcmRepoRoot}\LICENSE
72-
OutputBaseFilename={#GcmSetupExe}-win-{#GcmArch}-{#GcmVersionSimple}
83+
OutputBaseFilename={#GcmSetupExe}-{#GcmRuntimeIdentifier}-{#GcmVersionSimple}
7384
DefaultDirName={autopf}\{#GcmShortName}
7485
Compression=lzma2
7586
SolidCompression=yes

src/windows/Installer.Windows/layout.ps1

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
# Inputs
2-
param ([Parameter(Mandatory)] $Configuration, [Parameter(Mandatory)] $Output, $SymbolOutput)
2+
param ([Parameter(Mandatory)] $Configuration, [Parameter(Mandatory)] $Output, [Parameter(Mandatory)] $RuntimeIdentifier, $SymbolOutput)
33

44
Write-Output "Output: $Output"
55

6+
if ($RuntimeIdentifier -ne 'win-x86' -and $RuntimeIdentifier -ne 'win-x64' -and $RuntimeIdentifier -ne 'win-arm64') {
7+
Write-Host "Unsupported RuntimeIdentifier: $RuntimeIdentifier"
8+
exit 1
9+
}
10+
611
# Directories
712
$THISDIR = $PSScriptRoot
813
$ROOT = (Get-Item $THISDIR).Parent.Parent.Parent.FullName
@@ -41,15 +46,14 @@ Write-Output "Publishing core application..."
4146
dotnet publish "$GCM_SRC" `
4247
--framework net472 `
4348
--configuration "$Configuration" `
44-
--runtime win-x86 `
49+
--runtime $RuntimeIdentifier `
4550
--output "$PAYLOAD"
4651

4752
# Delete libraries that are not needed for Windows but find their way
4853
# into the publish output.
4954
Remove-Item -Path "$PAYLOAD/*.dylib" -Force -ErrorAction Ignore
5055

51-
# Delete extraneous files that get included for other architectures
52-
# We only care about x86 as the core GCM executable is only targeting x86
56+
# Delete extraneous files that get included for other runtimes
5357
Remove-Item -Path "$PAYLOAD/arm/" -Recurse -Force -ErrorAction Ignore
5458
Remove-Item -Path "$PAYLOAD/arm64/" -Recurse -Force -ErrorAction Ignore
5559
Remove-Item -Path "$PAYLOAD/x64/" -Recurse -Force -ErrorAction Ignore

0 commit comments

Comments
 (0)