Skip to content

Commit 45be25e

Browse files
committed
Switch to new sign tool
1 parent e3108d2 commit 45be25e

File tree

4 files changed

+28
-33
lines changed

4 files changed

+28
-33
lines changed

windows-release/sign-files.yml

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
parameters:
22
Include: '*'
33
Exclude: ''
4+
Filter: ''
45
WorkingDir: '$(Build.BinariesDirectory)'
56
ExtractDir: ''
67
SigningCertificate: ''
@@ -9,32 +10,13 @@ parameters:
910
steps:
1011
- ${{ if parameters.SigningCertificate }}:
1112
- powershell: |
12-
cd (mkdir -Force _signing)
13-
iwr https://aka.ms/nugetclidl -o nuget.exe
14-
.\nuget.exe install Microsoft.Windows.SDK.BuildTools -x -o .
15-
.\nuget.exe install Microsoft.Trusted.Signing.Client -x -o .
16-
$md = @{
17-
Endpoint='$(TrustedSigningUri)';
18-
CodeSigningAccountName='$(TrustedSigningAccount)';
19-
CertificateProfileName='$(TrustedSigningCertificateName)';
20-
CorrelationId='$(SigningDescription)';
21-
ExcludeEnvironmentCredential=$false;
22-
ExcludeManagedIdentityCredential=$true;
23-
ExcludeSharedTokenCacheCredential=$true;
24-
ExcludeVisualStudioCredential=$true;
25-
ExcludeVisualStudioCodeCredential=$true;
26-
ExcludeAzureCliCredential=$true;
27-
ExcludeAzurePowershellCredential=$true;
28-
ExcludeInteractiveBrowserCredential=$true;
29-
};
30-
# ConvertTo-Json $md | Out-File -Encoding UTF8 .\metadata.json
31-
# but without including the BOM...
32-
[System.IO.File]::WriteAllText("$(Get-Location)\metadata.json", (ConvertTo-Json $md), [System.Text.UTF8Encoding]::new($false))
13+
dotnet tool install --global --prerelease sign
14+
$signtool = (gcm sign).Source
15+
$signargs = 'code trusted-signing -v Information ' + `
16+
'-fd sha256 -t http://timestamp.acs.microsoft.com -td sha256 ' + `
17+
'-tse "$(TrustedSigningUri)" -tsa "$(TrustedSigningAccount)" -tscp "$(TrustedSigningCertificateName)" ' + `
18+
'-d "$(SigningDescription)" '
3319
34-
$signtool = dir .\Microsoft.Windows.SDK.BuildTools\*\*\x64\signtool.exe | select -First 1
35-
$dlib = dir .\Microsoft.Trusted.Signing.Client\*\x64\Azure.CodeSigning.Dlib.dll | select -First 1
36-
$signargs = "sign /v /fd sha256 /tr http://timestamp.acs.microsoft.com /td sha256 " + `
37-
"/dlib ""$dlib"" /dmdf ""$(gi metadata.json)"""
3820
Write-Host "##vso[task.setvariable variable=__TrustedSigningCmd]$signtool"
3921
Write-Host "##vso[task.setvariable variable=__TrustedSigningArgs]$signargs"
4022
if ($env:EXPORT_COMMAND) {
@@ -53,7 +35,13 @@ steps:
5335
} else {
5436
$files = (dir ${{ parameters.Include }} -File)
5537
}
56-
& $env:TRUSTED_SIGNING_CMD @(-split $env:TRUSTED_SIGNING_ARGS) $files
38+
if ($env:FILTER) {
39+
($env:FILTER -split ';') -join "`n" | Out-File __filelist.txt -Encoding utf8
40+
& $env:TRUSTED_SIGNING_CMD @(-split $env:TRUSTED_SIGNING_ARGS) -fl __filelist.txt $files
41+
del __filelist.txt
42+
} else {
43+
& $env:TRUSTED_SIGNING_CMD @(-split $env:TRUSTED_SIGNING_ARGS) $files
44+
}
5745
displayName: 'Sign binaries'
5846
retryCountOnTaskFailure: 3
5947
workingDirectory: ${{ parameters.WorkingDir }}
@@ -63,6 +51,8 @@ steps:
6351
AZURE_TENANT_ID: $(TrustedSigningTenantId)
6452
AZURE_CLIENT_ID: $(TrustedSigningClientId)
6553
AZURE_CLIENT_SECRET: $(TrustedSigningSecret)
54+
${{ if parameters.Filter }}:
55+
FILTER: ${{ parameters.Filter }}
6656
6757
6858
- ${{ if parameters.ExtractDir }}:

windows-release/stage-layout-msix.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ jobs:
6969
env:
7070
TCL_LIBRARY: $(TclLibrary)
7171
72-
- powershell: |
73-
$info = (gc "$(Pipeline.Workspace)\cert\certinfo.json" | ConvertFrom-JSON)
74-
Write-Host "Side-loadable APPX must be signed with '$($info.Subject)'"
75-
Write-Host "##vso[task.setvariable variable=APPX_DATA_PUBLISHER]$($info.Subject)"
76-
Write-Host "##vso[task.setvariable variable=APPX_DATA_SHA256]$($info.SHA256)"
77-
displayName: 'Override signing parameters'
78-
condition: and(succeeded(), variables['SigningCertificate'])
72+
# HACK: Disabled to test because new signing tool shouldn't need this
73+
#- powershell: |
74+
# $info = (gc "$(Pipeline.Workspace)\cert\certinfo.json" | ConvertFrom-JSON)
75+
# Write-Host "Side-loadable APPX must be signed with '$($info.Subject)'"
76+
# Write-Host "##vso[task.setvariable variable=APPX_DATA_PUBLISHER]$($info.Subject)"
77+
# Write-Host "##vso[task.setvariable variable=APPX_DATA_SHA256]$($info.SHA256)"
78+
# displayName: 'Override signing parameters'
79+
# condition: and(succeeded(), variables['SigningCertificate'])
7980

8081
- powershell: |
8182
Remove-Item "$(Build.ArtifactStagingDirectory)\appx" -Recurse -Force -EA 0

windows-release/stage-pack-msix.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ jobs:
131131
- template: sign-files.yml
132132
parameters:
133133
Include: '*.msix'
134+
# Additional filter to avoid recursively signing package contents
135+
Filter: '*.msix'
134136
WorkingDir: $(Build.BinariesDirectory)\unsigned_msix
135137
SigningCertificate: ${{ parameters.SigningCertificate }}
136138

windows-release/stage-pack-nuget.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ jobs:
6969
- template: sign-files.yml
7070
parameters:
7171
Include: '*.nupkg'
72+
# Additional filter to avoid recursively signing package contents
73+
Filter: '*.nupkg'
7274
WorkingDir: $(Build.ArtifactStagingDirectory)
7375
SigningCertificate: ${{ parameters.SigningCertificate }}
7476

0 commit comments

Comments
 (0)