@@ -50,6 +50,8 @@ function Find-EnvironmentVariables([string[]] $variables) {
50
50
}
51
51
}
52
52
53
+ Find-Dependencies @ (" dotnet.exe" , " wix.exe" )
54
+
53
55
if ($sign ) {
54
56
Write-Host " Signing is enabled"
55
57
Find-Dependencies java
@@ -97,7 +99,8 @@ if (Test-Path $outputPath.Replace(".exe", ".wixpdb")) {
97
99
}
98
100
99
101
# Create a publish directory
100
- $buildPath = Join-Path $repoRoot " publish\buildtemp-$ ( $version ) -$ ( $arch ) "
102
+ $publishDir = Join-Path $repoRoot " publish"
103
+ $buildPath = Join-Path $publishDir " buildtemp-$ ( $version ) -$ ( $arch ) "
101
104
if (Test-Path $buildPath ) {
102
105
Remove-Item - Recurse - Force $buildPath
103
106
}
@@ -164,7 +167,39 @@ Add-CoderSignature $msiOutputPath
164
167
-- msi- path $msiOutputPath `
165
168
-- logo- png " scripts\files\logo.png"
166
169
if ($LASTEXITCODE -ne 0 ) { throw " Failed to build bootstrapper" }
167
- Add-CoderSignature $outputPath
170
+
171
+ # Sign the bootstrapper, which is not as simple as just signing the exe.
172
+ if ($sign ) {
173
+ $burnIntermediate = Join-Path $publishDir " burn-intermediate-$ ( $version ) -$ ( $arch ) "
174
+ New-Item - ItemType Directory - Path $burnIntermediate - Force
175
+ $burnEngine = Join-Path $publishDir " burn-engine-$ ( $version ) -$ ( $arch ) .exe"
176
+
177
+ # Move the current output path
178
+ $unsignedOutputPath = Join-Path (Split-Path $outputPath - Parent) (" UNSIGNED-" + (Split-Path $outputPath - Leaf))
179
+ Move-Item $outputPath $unsignedOutputPath
180
+
181
+ # Extract the engine from the bootstrapper
182
+ & wix.exe burn detach $unsignedOutputPath - intermediateFolder $burnIntermediate - engine $burnEngine
183
+ if ($LASTEXITCODE -ne 0 ) { throw " Failed to extract engine from bootstrapper" }
184
+
185
+ # Sign the engine
186
+ Add-CoderSignature $burnEngine
187
+
188
+ # Re-attach the signed engine to the bootstrapper
189
+ & wix.exe burn reattach $unsignedOutputPath - intermediateFolder $burnIntermediate - engine $burnEngine - out $outputPath
190
+ if ($LASTEXITCODE -ne 0 ) { throw " Failed to re-attach signed engine to bootstrapper" }
191
+ if (! (Test-Path $outputPath )) { throw " Failed to create reattached bootstrapper at $outputPath " }
192
+
193
+ # Now sign the output path
194
+ Add-CoderSignature $outputPath
195
+
196
+ # Clean up the intermediate files
197
+ if (! $keepBuildTemp ) {
198
+ Remove-Item - Force $unsignedOutputPath
199
+ Remove-Item - Recurse - Force $burnIntermediate
200
+ Remove-Item - Force $burnEngine
201
+ }
202
+ }
168
203
169
204
if (! $keepBuildTemp ) {
170
205
Remove-Item - Recurse - Force $buildPath
0 commit comments