Skip to content

Commit a269567

Browse files
committed
Update build script
1 parent bddc7f4 commit a269567

1 file changed

Lines changed: 110 additions & 54 deletions

File tree

azure-pipelines.yml

Lines changed: 110 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,45 @@
1-
# Starter pipeline
2-
# Start with a minimal pipeline that you can customize to build and deploy your code.
3-
# Add steps that build, run tests, deploy, and more:
4-
# https://aka.ms/yaml
1+
parameters:
2+
- name: timestamper
3+
type: string
4+
displayName: Time Stamper URL
5+
default: 'http://timestamp.acs.microsoft.com'
6+
values:
7+
- 'http://timestamp.acs.microsoft.com'
8+
- 'http://timestamp.sectigo.com'
9+
- 'http://timestamp.digicert.com'
10+
- 'http://aatl-timestamp.globalsign.com/tsa/aohfewat2389535fnasgnlg5m23'
11+
- 'http://timestamp.entrust.net/TSS/RFC3161sha2TS'
12+
- 'http://kstamp.keynectis.com/KSign/'
13+
- 'http://tsa.quovadisglobal.com/TSS/HttpTspServer'
14+
- 'http://kstamp.keynectis.com/KSign/'
15+
- 'http://tss.accv.es:8318/tsa'
16+
- 'http://tsa.izenpe.com'
17+
- 'http://timestamp.sectigo.com/qualified'
18+
- 'http://timestamp.comodoca.com'
19+
- name: packagesigninginterval
20+
type: number
21+
displayName: Package Signing Interval
22+
default: 1
23+
- name: git_commit_ids
24+
type: string
25+
displayName: Build Commit IDs
26+
default: ' '
27+
- name: project_to_build
28+
type: string
29+
displayName: Project(s) to Build
30+
default: ' '
31+
- name: build_sdk
32+
type: boolean
33+
displayName: Force build MSBuild.SDK.SystemWeb
34+
default: false
35+
- name: build_razor_sdk
36+
type: boolean
37+
displayName: Force build MSBuild.SDK.SystemWeb.RazorLibrary
38+
default: false
39+
- name: build_templates
40+
type: boolean
41+
displayName: Force build MSBuild.SDK.SystemWeb.Templates
42+
default: false
543

644
trigger:
745
batch: true
@@ -30,14 +68,26 @@ variables:
3068
value: '$(Agent.MachineName)'
3169
- name: buildUser
3270
value: '$(Build.QueuedBy)'
33-
- name: 'timestamper'
34-
value: 'http://timestamp.comodoca.com'
3571

3672
steps:
3773
- checkout: self
3874
clean: true
3975
submodules: true
4076
persistCredentials: true
77+
fetchDepth: 0
78+
fetchTags: true
79+
80+
- powershell: 'Write-Host ("##vso[task.setvariable variable=project_to_build;]$($ENV:project_to_build);MSBuild.SDK.SystemWeb")'
81+
displayName: 'Force building MSBuild.SDK.SystemWeb'
82+
condition: eq(variables['build_sdk'],true)
83+
84+
- powershell: 'Write-Host ("##vso[task.setvariable variable=project_to_build;]$($env:project_to_build);MSBuild.SDK.SystemWeb.RazorLibrary")'
85+
displayName: 'Force building MSBuild.SDK.SystemWeb.RazorLibrary'
86+
condition: eq(variables['build_razor_sdk'],true)
87+
88+
- powershell: 'Write-Host ("##vso[task.setvariable variable=project_to_build;]$($env:project_to_build);MSBuild.SDK.SystemWeb.Templates")'
89+
displayName: 'Force building MSBuild.SDK.SystemWeb.Templates'
90+
condition: eq(variables['build_templates'],true)
4191

4292
- powershell: 'Write-Host ("##vso[task.setvariable variable=MSBuildEmitSolution;]0")'
4393
displayName: 'Ensure MSBuildEmitSolution is not set'
@@ -47,19 +97,20 @@ steps:
4797
name: snk
4898
inputs:
4999
secureFile: '61ad38e7-05ff-4421-aea8-e3241b75c7a1'
50-
51-
- task: PowerShell@2
52-
displayName: 'Install Certificate'
100+
101+
- task: NuGetToolInstaller@1
102+
displayName: 'Use NuGet >=6.6.1'
53103
inputs:
54-
targetType: 'filePath'
55-
filePath: 'build/ImportCert.ps1'
56-
env:
57-
password: $(pfx-password)
58-
pfx: $(c3d-codesign)
104+
versionSpec: '>=6.6.1'
105+
checkLatest: true
59106

60-
- task: NuGetToolInstaller@0
107+
# Install the code signing tool
108+
- task: DotNetCoreCLI@2
61109
inputs:
62-
versionSpec: 5.8.1
110+
command: custom
111+
custom: tool
112+
arguments: update sign --global --version 0.9.1-beta.23530.1
113+
displayName: Install SignTool tool
63114

64115
- task: NuGetCommand@2
65116
inputs:
@@ -93,23 +144,37 @@ steps:
93144
Write-Host "Packages: $ids"
94145
Write-Host "Package Count: $($packages.Count)"
95146
Write-Host ("##vso[task.setvariable variable=package_count;]$($packages.Count)")
96-
97-
- task: NuGetCommand@2
147+
148+
# Run the signing command
149+
- task: PowerShell@2
150+
displayName: Sign packages
98151
condition: and(succeeded(), ne(variables['package_count'],0))
99-
displayName: 'NuGet Sign'
100152
inputs:
101-
command: custom
102-
arguments: 'sign $(Build.ArtifactStagingDirectory)\*.nupkg -Timestamper $(timestamper) -CertificateFingerprint $(app_pfx_thumbprint)'
103-
153+
targetType: inline
154+
script: |
155+
sign code azure-key-vault `
156+
"**/*.nupkg" `
157+
--base-directory "$(Build.ArtifactStagingDirectory)" `
158+
-d "Cynthia Z E MacLeod" `
159+
-u "https://github.com/CZEMacLeod" `
160+
-kvu "https://c3d-devops.vault.azure.net/" `
161+
-kvc "c3d-codesign" `
162+
-v information `
163+
-t "$(timestamper)" `
164+
--azure-key-vault-tenant-id "$(SignTenantId)" `
165+
--azure-key-vault-client-id "$(SignClientId)" `
166+
--azure-key-vault-client-secret '$(SignClientSecret)'
104167
105168
- task: CopyFiles@2
169+
condition: and(succeeded(), ne(variables['package_count'],0))
106170
displayName: Create nuget publish config
107171
inputs:
108-
sourceFolder: $(Build.SourcesDirectory)
172+
sourceFolder: '$(Build.SourcesDirectory)\build'
109173
contents: 'nuget.publish.config'
110174
targetFolder: $(Build.ArtifactStagingDirectory)
111175

112176
- task: PowerShell@2
177+
condition: and(succeeded(), ne(variables['package_count'],0))
113178
displayName: Build Nuget Source URL
114179
inputs:
115180
targetType: 'inline'
@@ -122,6 +187,7 @@ steps:
122187
GITHUB_OWNER: $(GITHUB_OWNER)
123188

124189
- script: nuget.exe sources Add -NonInteractive -Name GitHub -Source "%NUGET_SOURCE%" -Username "%GITHUB_USERNAME%" -Password "%GITHUB_TOKEN%" -ConfigFile %NUGET_CONFIG%
190+
condition: and(succeeded(), ne(variables['package_count'],0))
125191
displayName: Add github package source
126192
env:
127193
GITHUB_OWNER: $(GITHUB_OWNER)
@@ -132,33 +198,30 @@ steps:
132198

133199
- script: nuget push -Source GitHub -ConfigFile %NUGET_CONFIG% -SkipDuplicate "%PACKAGES_DIR%\*.nupkg"
134200
displayName: Push Nuget Packages to $(GITHUB_PACKAGES)
201+
condition: and(succeeded(), ne(variables['package_count'],0))
135202
env:
136203
PACKAGES_DIR: $(Build.ArtifactStagingDirectory)
137204
NUGET_CONFIG: $(Build.ArtifactStagingDirectory)\nuget.publish.config
138205

139-
#- task: NuGetCommand@2
140-
# displayName: Push Nuget Packages to $(GITHUB_PACKAGES)
141-
# inputs:
142-
# command: 'push'
143-
# feedsToUse: 'config'
144-
# publishFeedCredentials: 'github-czemacleod-packages'
145-
# externalFeedCredentials: 'github-czemacleod-packages'
146-
# packagesToPush: $(Build.ArtifactStagingDirectory)\*.nupkg
147-
# verbosityPush: 'Detailed'
148-
# nuGetFeedType: 'external'
206+
- script: nuget.exe sources Add -NonInteractive -Name NuGet -Source "https://api.nuget.org/v3/index.json" -ConfigFile %NUGET_CONFIG%
207+
condition: and(succeeded(), ne(variables['package_count'],0))
208+
displayName: Add nuget.org package source
209+
env:
210+
NUGET_CONFIG: $(Build.ArtifactStagingDirectory)\nuget.publish.config
211+
212+
- script: nuget.exe setapikey %NUGET_API_KEY% -Source "https://api.nuget.org/v3/index.json" -ConfigFile %NUGET_CONFIG%
213+
condition: and(succeeded(), ne(variables['package_count'],0))
214+
displayName: Set nuget.org apikey
215+
env:
216+
NUGET_API_KEY: $(NUGET_API_KEY)
217+
NUGET_CONFIG: $(Build.ArtifactStagingDirectory)\nuget.publish.config
149218

150-
- task: NuGetCommand@2
219+
- script: nuget push -Source NuGet -ConfigFile %NUGET_CONFIG% -SkipDuplicate "%PACKAGES_DIR%\*.nupkg"
151220
displayName: Push Nuget Packages to nuget.org
152-
inputs:
153-
command: 'push'
154-
feedsToUse: 'config'
155-
includeNugetOrg: 'true'
156-
publishFeedCredentials: 'NuGet.org'
157-
externalFeedCredentials: 'NuGet.org'
158-
packagesToPush: $(Build.ArtifactStagingDirectory)\*.nupkg
159-
verbosityPush: 'Detailed'
160-
nuGetFeedType: 'external'
161-
allowPackageConflicts: true
221+
condition: and(succeeded(), ne(variables['package_count'],0))
222+
env:
223+
PACKAGES_DIR: $(Build.ArtifactStagingDirectory)
224+
NUGET_CONFIG: $(Build.ArtifactStagingDirectory)\nuget.publish.config
162225

163226
- powershell: |
164227
Write-Host "Tagging Build: $env:BuildNumber"
@@ -171,17 +234,10 @@ steps:
171234
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
172235

173236
- task: GithubRelease@0
174-
displayName: 'Create GitHub Release'
237+
displayName: 'Create GitHub Release'
238+
condition: and(succeeded(), ne(variables['package_count'],0))
175239
inputs:
176240
gitHubConnection: github-czemacleod
177-
repositoryName: CZEMacLeod/MSBuild.SDK.SystemWeb
241+
repositoryName: CZEMacLeod/MSBuild.SDK.SystemWeb
178242
assets: $(Build.ArtifactStagingDirectory)/*.nupkg
179243
addChangeLog: true
180-
181-
- task: PowerShell@2
182-
displayName: 'Remove Cert'
183-
inputs:
184-
targetType: filePath
185-
filePath: 'build/RemoveCert.ps1'
186-
arguments: '-thumb $(app_pfx_thumbprint)'
187-
condition: always()

0 commit comments

Comments
 (0)