Skip to content

Commit 96c52e4

Browse files
authored
Merge pull request #197 from mjcheetham/winstall-split
Split Windows installer in to user/system flavours
2 parents aca1953 + 4f12cc7 commit 96c52e4

File tree

2 files changed

+64
-23
lines changed

2 files changed

+64
-23
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="Tools.InnoSetup" Version="5.6.1" />
21+
<PackageReference Include="Tools.InnoSetup" Version="6.0.5" />
2222
<PackageReference Include="MicroBuild.Core" Version="0.2.0">
2323
<PrivateAssets>all</PrivateAssets>
2424
</PackageReference>
@@ -29,7 +29,7 @@
2929
before we attempt to sign any files or validate they exist. -->
3030
<Target Name="CreateFilesToSignItems" DependsOnTargets="GetBuildVersion" BeforeTargets="PrepareForRun">
3131
<ItemGroup>
32-
<FilesToSign Include="$(OutDir)gcmcore-win-x86-$(BuildVersion).exe">
32+
<FilesToSign Include="$(OutDir)gcmcore*-win-x86-$(BuildVersion).exe">
3333
<Authenticode>Microsoft400</Authenticode>
3434
<InProject>false</InProject>
3535
</FilesToSign>
@@ -47,10 +47,13 @@
4747

4848
<Target Name="CoreCompile" Condition="'$(OSPlatform)'=='windows'">
4949
<PropertyGroup>
50-
<InnoSetupCommand>$(NuGetPackageRoot)Tools.InnoSetup\5.6.1\tools\ISCC.exe /DPayloadDir=$(PayloadPath) Setup.iss /O$(OutputPath)</InnoSetupCommand>
50+
<InnoSetupCommandSystem>$(NuGetPackageRoot)Tools.InnoSetup\6.0.5\tools\ISCC.exe /DPayloadDir=$(PayloadPath) /DInstallTarget=system Setup.iss /O$(OutputPath)</InnoSetupCommandSystem>
51+
<InnoSetupCommandUser>$(NuGetPackageRoot)Tools.InnoSetup\6.0.5\tools\ISCC.exe /DPayloadDir=$(PayloadPath) /DInstallTarget=user Setup.iss /O$(OutputPath)</InnoSetupCommandUser>
5152
</PropertyGroup>
52-
<Message Text="$(InnoSetupCommand)" Importance="High" />
53-
<Exec Command="$(InnoSetupCommand)" />
53+
<Message Text="$(InnoSetupCommandSystem)" Importance="High" />
54+
<Exec Command="$(InnoSetupCommandSystem)" />
55+
<Message Text="$(InnoSetupCommandUser)" Importance="High" />
56+
<Exec Command="$(InnoSetupCommandUser)" />
5457
</Target>
5558

5659
<!-- We don't produce or copy any dependent files for this project -->
@@ -59,4 +62,4 @@
5962
<RemoveDir Directories="$(ProjectOutPath)" />
6063
</Target>
6164

62-
</Project>
65+
</Project>

src/windows/Installer.Windows/Setup.iss

Lines changed: 55 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,63 @@
1-
; This script requires Inno Setup Compiler 5.6.1 or later to compile
1+
; This script requires Inno Setup Compiler 6.0.0 or later to compile
22
; The Inno Setup Compiler (and IDE) can be found at http://www.jrsoftware.org/isinfo.php
33
; General documentation on how to use InnoSetup scripts: http://www.jrsoftware.org/ishelp/index.php
44

55
; Ensure minimum Inno Setup tooling version
6-
#if VER < EncodeVer(5,6,1)
7-
#error Update your Inno Setup version (5.6.1 or newer)
6+
#if VER < EncodeVer(6,0,0)
7+
#error Update your Inno Setup version (6.0.0 or newer)
88
#endif
99

1010
#ifndef PayloadDir
1111
#error Payload directory path property 'PayloadDir' must be specified
1212
#endif
1313

14-
#ifnexist PayloadDir + "\git-credential-manager-core.exe"
15-
#error Payload files are missing
14+
#ifndef InstallTarget
15+
#error Installer target property 'InstallTarget' must be specifed
16+
#endif
17+
18+
#if InstallTarget == "user"
19+
#define GcmAppId "{{aa76d31d-432c-42ee-844c-bc0bc801cef3}}"
20+
#define GcmLongName "Git Credential Manager Manager Core (User)"
21+
#define GcmSetupExe "gcmcoreuser"
22+
#define GcmConfigureCmdArgs "--user"
23+
#elif InstallTarget == "system"
24+
#define GcmAppId "{{fdfae50a-1bc1-4ead-9228-1e1c275e8d12}}"
25+
#define GcmLongName "Git Credential Manager Manager Core"
26+
#define GcmSetupExe "gcmcore"
27+
#define GcmConfigureCmdArgs "--system"
28+
#else
29+
#error Installer target property 'InstallTarget' must be 'user' or 'system'
1630
#endif
1731

1832
; Define core properties
19-
#define GcmName "Git Credential Manager Core"
33+
#define GcmShortName "Git Credential Manager Core"
2034
#define GcmPublisher "Microsoft Corporation"
2135
#define GcmPublisherUrl "https://www.microsoft.com"
22-
#define GcmCopyright "Copyright (c) Microsoft 2019"
23-
#define GcmUrl "https://github.com/microsoft/Git-Credential-Manager-Core"
36+
#define GcmCopyright "Copyright (c) Microsoft 2020"
37+
#define GcmUrl "https://aka.ms/gcmcore"
2438
#define GcmReadme "https://github.com/microsoft/Git-Credential-Manager-Core/blob/master/README.md"
2539
#define GcmRepoRoot "..\..\.."
2640
#define GcmAssets GcmRepoRoot + "\assets"
41+
#define GcmExe "git-credential-manager-core.exe"
42+
#define GcmArch "x86"
43+
44+
#ifnexist PayloadDir + "\" + GcmExe
45+
#error Payload files are missing
46+
#endif
2747

2848
; Generate the GCM version version from the CLI executable
2949
#define VerMajor
3050
#define VerMinor
3151
#define VerBuild
3252
#define VerRevision
33-
#expr ParseVersion(PayloadDir + "\git-credential-manager-core.exe", VerMajor, VerMinor, VerBuild, VerRevision)
53+
#expr ParseVersion(PayloadDir + "\" + GcmExe, VerMajor, VerMinor, VerBuild, VerRevision)
3454
#define GcmVersion str(VerMajor) + "." + str(VerMinor) + "." + str(VerBuild) + "." + str(VerRevision)
3555

3656
[Setup]
37-
AppId={{fdfae50a-1bc1-4ead-9228-1e1c275e8d12}}
38-
AppName={#GcmName}
57+
AppId={#GcmAppId}
58+
AppName={#GcmLongName}
3959
AppVersion={#GcmVersion}
40-
AppVerName={#GcmName} {#GcmVersion}
60+
AppVerName={#GcmLongName} {#GcmVersion}
4161
AppPublisher={#GcmPublisher}
4262
AppPublisherURL={#GcmPublisherUrl}
4363
AppSupportURL={#GcmUrl}
@@ -47,20 +67,23 @@ AppCopyright={#GcmCopyright}
4767
AppReadmeFile={#GcmReadme}
4868
VersionInfoVersion={#GcmVersion}
4969
LicenseFile={#GcmRepoRoot}\LICENSE
50-
OutputBaseFilename=gcmcore-win-x86-{#GcmVersion}
51-
DefaultDirName={pf}\{#GcmName}
70+
OutputBaseFilename={#GcmSetupExe}-win-{#GcmArch}-{#GcmVersion}
71+
DefaultDirName={autopf}\{#GcmShortName}
5272
Compression=lzma2
5373
SolidCompression=yes
5474
MinVersion=6.1.7600
5575
DisableDirPage=yes
56-
UninstallDisplayIcon={app}\git-credential-manager-core.exe
76+
UninstallDisplayIcon={app}\{#GcmExe}
5777
SetupIconFile={#GcmAssets}\gcmicon.ico
5878
WizardImageFile={#GcmAssets}\gcmicon128.bmp
5979
WizardSmallImageFile={#GcmAssets}\gcmicon64.bmp
6080
WizardStyle=modern
6181
WizardImageStretch=no
6282
WindowResizable=no
6383
ChangesEnvironment=yes
84+
#if InstallTarget == "user"
85+
PrivilegesRequired=lowest
86+
#endif
6487

6588
[Languages]
6689
Name: english; MessagesFile: "compiler:Default.isl";
@@ -72,10 +95,10 @@ Name: full; Description: "Full installation"; Flags: iscustom;
7295
; No individual components
7396

7497
[Run]
75-
Filename: "{app}\git-credential-manager-core.exe"; Parameters: "configure"; Flags: runhidden
98+
Filename: "{app}\{#GcmExe}"; Parameters: "configure {#GcmConfigureCmdArgs}"; Flags: runhidden
7699

77100
[UninstallRun]
78-
Filename: "{app}\git-credential-manager-core.exe"; Parameters: "unconfigure"; Flags: runhidden
101+
Filename: "{app}\{#GcmExe}"; Parameters: "unconfigure {#GcmConfigureCmdArgs}"; Flags: runhidden
79102

80103
[Files]
81104
Source: "{#PayloadDir}\Atlassian.Bitbucket.dll"; DestDir: "{app}"; Flags: ignoreversion
@@ -95,3 +118,18 @@ Source: "{#PayloadDir}\Microsoft.IdentityModel.JsonWebTokens.dll"; DestDir:
95118
Source: "{#PayloadDir}\Microsoft.IdentityModel.Logging.dll"; DestDir: "{app}"; Flags: ignoreversion
96119
Source: "{#PayloadDir}\Microsoft.IdentityModel.Tokens.dll"; DestDir: "{app}"; Flags: ignoreversion
97120
Source: "{#PayloadDir}\Newtonsoft.Json.dll"; DestDir: "{app}"; Flags: ignoreversion
121+
122+
[Code]
123+
// Don't allow installing conflicting architectures
124+
function InitializeSetup(): Boolean;
125+
begin
126+
Result := True;
127+
128+
#if InstallTarget == "user"
129+
if not WizardSilent() and IsAdmin() then begin
130+
if MsgBox('This User Installer is not meant to be run as an Administrator. If you would like to install Git Credential Manager Core for all users in this system, download the System Installer instead from https://aka.ms/gcmcore-latest. Are you sure you want to continue?', mbError, MB_OKCANCEL) = IDCANCEL then begin
131+
Result := False;
132+
end;
133+
end;
134+
#endif
135+
end;

0 commit comments

Comments
 (0)