Skip to content

Commit abdda8a

Browse files
committed
cleanup: simplify code signing targets
1 parent 8a238df commit abdda8a

File tree

4 files changed

+29
-38
lines changed

4 files changed

+29
-38
lines changed

.config/dotnet-tools.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"azuresigntool": {
6+
"version": "2.0.17",
7+
"commands": [
8+
"azuresigntool"
9+
]
10+
},
11+
"nugetkeyvaultsigntool": {
12+
"version": "1.2.28",
13+
"commands": [
14+
"NuGetKeyVaultSignTool"
15+
]
16+
}
17+
}
18+
}

azure-pipelines.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ pr:
99
- '*'
1010

1111
variables:
12-
- name: kv-access-token
13-
value: ''
1412
- group: AzureKeyVault
15-
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
16-
value: 1
1713
- name: BUILD_NUMBER
1814
value: $[counter('buildnumber', 1)]
1915

@@ -38,10 +34,8 @@ stages:
3834
packageType: runtime
3935
- powershell: ./build.ps1 -ci
4036
displayName: Invoke build.ps1
41-
condition: eq(variables['kv-access-token'], '')
42-
- powershell: ./build.ps1 -ci /p:AzureKeyVaultClientSecret=$(kv-access-token)
43-
displayName: Invoke build.ps1
44-
condition: ne(variables['kv-access-token'], '')
37+
env:
38+
KEYVAULT_CLIENT_SECRET: kv-access-token
4539
- powershell: .\docs\generate.ps1 -Verbose -NoBuild
4640
displayName: Compile documentation
4741
- task: PublishTestResults@2

build.ps1

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ Import-Module -Force -Scope Local "$PSScriptRoot/src/common.psm1"
2020
# Main
2121
#
2222

23+
$isPr = $env:BUILD_REASON -eq 'PullRequest'
24+
2325
if ($env:CI -eq 'true') {
2426
$ci = $true
27+
& dotnet --info
2528
}
2629

2730
if (!$Configuration) {
@@ -32,44 +35,23 @@ if ($ci) {
3235
$MSBuildArgs += '-p:CI=true'
3336
}
3437

35-
$isPr = $env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT -or ($env:BUILD_REASON -eq 'PullRequest')
3638
if (-not (Test-Path variable:\IsCoreCLR)) {
3739
$IsWindows = $true
3840
}
3941

4042
$CodeSign = $sign -or ($ci -and -not $isPr -and $IsWindows)
4143

4244
if ($CodeSign) {
43-
$toolsDir = "$PSScriptRoot/.build/tools"
44-
$AzureSignToolPath = "$toolsDir/azuresigntool"
45-
if ($IsWindows) {
46-
$AzureSignToolPath += ".exe"
47-
}
48-
49-
if (-not (Test-Path $AzureSignToolPath)) {
50-
exec dotnet tool install --tool-path $toolsDir `
51-
AzureSignTool `
52-
--version 2.0.17
53-
}
54-
55-
$nstDir = "$toolsDir/nugetsigntool/1.1.4"
56-
$NuGetKeyVaultSignToolPath = "$nstDir/tools/net471/NuGetKeyVaultSignTool.exe"
57-
if (-not (Test-Path $NuGetKeyVaultSignToolPath)) {
58-
New-Item $nstDir -ItemType Directory -ErrorAction Ignore | Out-Null
59-
Invoke-WebRequest https://github.com/onovotny/NuGetKeyVaultSignTool/releases/download/v1.1.4/NuGetKeyVaultSignTool.1.1.4.nupkg `
60-
-OutFile "$nstDir/NuGetKeyVaultSignTool.zip"
61-
Expand-Archive "$nstDir/NuGetKeyVaultSignTool.zip" -DestinationPath $nstDir
62-
}
63-
45+
exec dotnet tool restore
6446
$MSBuildArgs += '-p:CodeSign=true'
65-
$MSBuildArgs += "-p:AzureSignToolPath=$AzureSignToolPath"
66-
$MSBuildArgs += "-p:NuGetKeyVaultSignToolPath=$NuGetKeyVaultSignToolPath"
6747
}
6848

6949
$artifacts = "$PSScriptRoot/artifacts/"
7050

7151
Remove-Item -Recurse $artifacts -ErrorAction Ignore
72-
exec dotnet msbuild /t:UpdateCiSettings @MSBuildArgs
52+
if ($ci) {
53+
exec dotnet msbuild /t:UpdateCiSettings @MSBuildArgs
54+
}
7355
exec dotnet build --configuration $Configuration '-warnaserror:CS1591' @MSBuildArgs
7456
exec dotnet pack --no-restore --no-build --configuration $Configuration -o $artifacts @MSBuildArgs
7557
exec dotnet build --configuration $Configuration "$PSScriptRoot/docs/samples/samples.sln"

src/CodeSign.targets

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
Inputs="$(TargetPath)"
1313
Outputs="$(CodeSignCacheFile)">
1414

15-
<Error Text="Missing required property: AzureSignToolPath" Condition="'$(AzureSignToolPath)' == ''" />
16-
1715
<PropertyGroup>
18-
<SignToolArgs>"$(AzureSignToolPath)" sign</SignToolArgs>
16+
<SignToolArgs>dotnet tool run azuresigntool sign</SignToolArgs>
1917
<SignToolArgs>$(SignToolArgs) --file-digest sha256</SignToolArgs>
2018
<SignToolArgs>$(SignToolArgs) --description-url $(PackageProjectUrl)</SignToolArgs>
2119
<SignToolArgs>$(SignToolArgs) --no-page-hashing</SignToolArgs>
@@ -38,12 +36,11 @@
3836
BeforeTargets="Pack"
3937
Inputs="$(PackageOutputAbsolutePath)$(PackageId).$(PackageVersion).nupkg"
4038
Outputs="$(PackageSignCacheFile)">
41-
<Error Text="Missing required property: NuGetKeyVaultSignToolPath" Condition="'$(NuGetKeyVaultSignToolPath)' == ''" />
4239

4340
<PropertyGroup>
4441
<NupkgTargetPath>$(PackageOutputAbsolutePath)$(PackageId).$(PackageVersion).nupkg</NupkgTargetPath>
4542

46-
<NupkgSignToolArgs>"$(NuGetKeyVaultSignToolPath)" sign</NupkgSignToolArgs>
43+
<NupkgSignToolArgs>dotnet tool run NuGetKeyVaultSignTool sign</NupkgSignToolArgs>
4744
<NupkgSignToolArgs>$(NupkgSignToolArgs) --file-digest sha256</NupkgSignToolArgs>
4845
<NupkgSignToolArgs>$(NupkgSignToolArgs) --timestamp-rfc3161 http://timestamp.digicert.com</NupkgSignToolArgs>
4946
<NupkgSignToolArgs>$(NupkgSignToolArgs) --timestamp-digest sha256</NupkgSignToolArgs>

0 commit comments

Comments
 (0)