-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
azure-pipelines.yml
417 lines (382 loc) · 16.9 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
name: 'vNext$(rev:.r)' # Format for build number (will be overridden)
#trigger:
#- master
# DevOps Setup: Define the following pipeline level variables in Azure DevOps build pipeline
#
# ArtifactFeedID: (Optional - set to your Azure DevOps Artifact (NuGet) feed. If not provided, publish job will be skipped.)
# BuildConfiguration: 'Release' (Optional - the solution build configuration to run.)
# BuildPlatform: 'Any CPU' (Optional - the build platform to use when compiling assemblies.)
# RunTests: 'true' (Optional - set to 'false' to disable test jobs - useful for debugging. If not provided, tests will be run.)
# RunX86Tests: 'false' (Optional - set to 'true' to enable x86 tests)
#
# PackageVersion: '' (Optional. Will be generated from nbgv if not provided. The version of the NuGet package.)
# AssemblyVersion: '' (Optional. Will be generated from nbgv if not provided. The assembly version (affects binary compatibility). This should always be the same as the previous version unless a binary breaking change happens (i.e. porting a new version).)
# FileVersion: '' (Optional. Will be generated from nbgv if not provided. The version that is visible on the assembly file.)
# InformationalVersion: '' (Optional. Will be generated from nbgv if not provided. If provided, the git commit hash will be appended to the end of the value.)
variables:
- name: TestTargetFrameworks
value: 'net9.0;net8.0;net6.0;net48;net472;net471;net47'
- name: DotNetSDKVersion
value: '9.0.100'
- name: BinaryArtifactName
value: 'testbinaries'
- name: NuGetArtifactName
value: 'nuget'
- name: TestResultsArtifactName
value: 'testresults'
- name: VersionArtifactName
value: 'version'
- name: BuildNumberFileName
value: 'buildNumber.txt'
- name: PackageVersionFileName
value: 'packageVersion.txt'
- name: FileVersionFileName
value: 'fileVersion.txt'
stages:
- stage: Build_Stage
displayName: 'Build Stage:'
jobs:
- job: Build
pool:
vmImage: 'windows-2019'
steps:
# Nerdbank.GitVersioning requires a deep clone. See: https://github.com/dotnet/Nerdbank.GitVersioning/blob/main/doc/cloudbuild.md#azure-pipelines
- checkout: self
fetchDepth: 0
#- template: '.build/azure-templates/show-all-files.yml' # for debugging
#- pwsh: C:;cd $env:ANDROID_HOME;dir -r | Where-Object {$_.PsIsContainer -eq $false} | % { $_.FullName }
- pwsh: |
$configuration = if ($env:BUILDCONFIGURATION) { $env:BUILDCONFIGURATION } else { "Release" }
Write-Host "##vso[task.setvariable variable=BuildConfiguration;]$configuration"
$platform = if ($env:BUILDPLATFORM) { $env:BUILDPLATFORM } else { "Any CPU" }
Write-Host "##vso[task.setvariable variable=BuildPlatform;]$platform"
$informationalVersion = if ($env:INFORMATIONALVERSION) { $env:INFORMATIONALVERSION } else { '' }
Write-Host "##vso[task.setvariable variable=InformationalVersion;]$informationalVersion"
$fileVersion = if ($env:FILEVERSION) { $env:FILEVERSION } else { '' }
Write-Host "##vso[task.setvariable variable=FileVersion;]$fileVersion"
$assemblyVersion = if ($env:ASSEMBLYVERSION) { $env:ASSEMBLYVERSION } else { '' }
Write-Host "##vso[task.setvariable variable=AssemblyVersion;]$assemblyVersion"
$packageVersion = if ($env:PACKAGEVERSION) { $env:PACKAGEVERSION } else { '' }
Write-Host "##vso[task.setvariable variable=PackageVersion;]$packageVersion"
displayName: 'Setup Default Variable Values'
- template: '.build/azure-templates/install-dotnet-sdk.yml'
parameters:
sdkVersion: '$(DotNetSDKVersion)'
- template: '.build/azure-templates/gitversioning-increment-and-persist-versions.yml'
parameters:
informationalVersion: '$(InformationalVersion)' # Input passed in from pipeline
fileVersion: '$(FileVersion)' # Input passed in from pipeline
assemblyVersion: '$(AssemblyVersion)' # Input passed in from pipeline
packageVersion: '$(PackageVersion)' # Input passed in from pipeline
versionArtifactName: '$(VersionArtifactName)'
packageVersionFileName: '$(PackageVersionFileName)'
fileVersionFileName: '$(FileVersionFileName)'
buildNumberFileName: '$(BuildNumberFileName)'
- template: '.build/azure-templates/build-pack-and-publish-libraries.yml'
parameters:
artifactFeedID: '$(ArtifactFeedID)'
testTargetFrameworks: '$(TestTargetFrameworks)'
informationalVersion: '$(CI_InformationalVersion)' # Output from gitversioning-increment-and-persist-versions.yml
fileVersion: '$(CI_FileVersion)' # Output from gitversioning-increment-and-persist-versions.yml
assemblyVersion: '$(CI_AssemblyVersion)' # Output from gitversioning-increment-and-persist-versions.yml
packageVersion: '$(CI_PackageVersion)' # Output from gitversioning-increment-and-persist-versions.yml
buildConfiguration: '$(BuildConfiguration)'
buildPlatform: '$(BuildPlatform)'
nugetArtifactName: '$(NuGetArtifactName)'
binaryArtifactName: '$(BinaryArtifactName)'
- task: PublishPipelineArtifact@1
displayName: 'Publish Artifact: $(BinaryArtifactName)'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/$(BinaryArtifactName)'
artifact: '$(BinaryArtifactName)'
publishLocation: 'pipeline'
condition: succeededOrFailed()
- stage: Test_Stage
displayName: 'Test Stage:'
jobs:
- job: Test_net48_x64
condition: and(succeeded(), ne(variables['RunTests'], 'false'))
displayName: 'Test net48,x64 on Windows'
pool:
vmImage: 'windows-latest'
steps:
- template: '.build/azure-templates/run-tests-on-os.yml'
parameters:
osName: 'Windows'
testTargetFramework: 'net48'
vsTestPlatform: 'x64'
testResultsArtifactName: '$(TestResultsArtifactName)'
maximumAllowedFailures: 0 # Maximum allowed failures for a successful build
dotNetSdkVersion: '$(DotNetSDKVersion)'
- job: Test_net48_x86 # Only run if explicitly enabled with RunX86Tests
condition: and(succeeded(), ne(variables['RunTests'], 'false'), eq(variables['RunX86Tests'], 'true'))
displayName: 'Test net48,x86 on Windows'
pool:
vmImage: 'windows-latest'
steps:
- template: '.build/azure-templates/run-tests-on-os.yml'
parameters:
osName: 'Windows'
testTargetFramework: 'net48'
vsTestPlatform: 'x86'
testResultsArtifactName: '$(TestResultsArtifactName)'
maximumAllowedFailures: 0 # Maximum allowed failures for a successful build
dotNetSdkVersion: '$(DotNetSDKVersion)'
- job: Test_net472_x64
condition: and(succeeded(), ne(variables['RunTests'], 'false'))
displayName: 'Test net472,x64 on Windows'
pool:
vmImage: 'windows-latest'
steps:
- template: '.build/azure-templates/run-tests-on-os.yml'
parameters:
osName: 'Windows'
testTargetFramework: 'net472'
vsTestPlatform: 'x64'
testResultsArtifactName: '$(TestResultsArtifactName)'
maximumAllowedFailures: 0 # Maximum allowed failures for a successful build
dotNetSdkVersion: '$(DotNetSDKVersion)'
- job: Test_net472_x86 # Only run if explicitly enabled with RunX86Tests
condition: and(succeeded(), ne(variables['RunTests'], 'false'), eq(variables['RunX86Tests'], 'true'))
displayName: 'Test net472,x86 on Windows'
pool:
vmImage: 'windows-latest'
steps:
- template: '.build/azure-templates/run-tests-on-os.yml'
parameters:
osName: 'Windows'
testTargetFramework: 'net472'
vsTestPlatform: 'x86'
testResultsArtifactName: '$(TestResultsArtifactName)'
maximumAllowedFailures: 0 # Maximum allowed failures for a successful build
dotNetSdkVersion: '$(DotNetSDKVersion)'
- job: Test_net471_x64
condition: and(succeeded(), ne(variables['RunTests'], 'false'))
displayName: 'Test net471,x64 on Windows'
pool:
vmImage: 'windows-latest'
steps:
- template: '.build/azure-templates/run-tests-on-os.yml'
parameters:
osName: 'Windows'
testTargetFramework: 'net471'
vsTestPlatform: 'x64'
testResultsArtifactName: '$(TestResultsArtifactName)'
maximumAllowedFailures: 0 # Maximum allowed failures for a successful build
dotNetSdkVersion: '$(DotNetSDKVersion)'
- job: Test_net471_x86 # Only run if explicitly enabled with RunX86Tests
condition: and(succeeded(), ne(variables['RunTests'], 'false'), eq(variables['RunX86Tests'], 'true'))
displayName: 'Test net471,x86 on Windows'
pool:
vmImage: 'windows-latest'
steps:
- template: '.build/azure-templates/run-tests-on-os.yml'
parameters:
osName: 'Windows'
testTargetFramework: 'net471'
vsTestPlatform: 'x86'
testResultsArtifactName: '$(TestResultsArtifactName)'
maximumAllowedFailures: 0 # Maximum allowed failures for a successful build
dotNetSdkVersion: '$(DotNetSDKVersion)'
- job: Test_net47_x64
condition: and(succeeded(), ne(variables['RunTests'], 'false'))
displayName: 'Test net47,x64 on Windows'
pool:
vmImage: 'windows-latest'
steps:
- template: '.build/azure-templates/run-tests-on-os.yml'
parameters:
osName: 'Windows'
testTargetFramework: 'net47'
vsTestPlatform: 'x64'
testResultsArtifactName: '$(TestResultsArtifactName)'
maximumAllowedFailures: 0 # Maximum allowed failures for a successful build
dotNetSdkVersion: '$(DotNetSDKVersion)'
- job: Test_net47_x86 # Only run if explicitly enabled with RunX86Tests
condition: and(succeeded(), ne(variables['RunTests'], 'false'), eq(variables['RunX86Tests'], 'true'))
displayName: 'Test net47,x86 on Windows'
pool:
vmImage: 'windows-latest'
steps:
- template: '.build/azure-templates/run-tests-on-os.yml'
parameters:
osName: 'Windows'
testTargetFramework: 'net47'
vsTestPlatform: 'x86'
testResultsArtifactName: '$(TestResultsArtifactName)'
maximumAllowedFailures: 0 # Maximum allowed failures for a successful build
dotNetSdkVersion: '$(DotNetSDKVersion)'
- job: Test_net9_0_x64
condition: and(succeeded(), ne(variables['RunTests'], 'false'))
strategy:
matrix:
Windows:
osName: 'Windows'
imageName: 'windows-latest'
maximumAllowedFailures: 0 # Maximum allowed failures for a successful build
Linux:
osName: 'Linux'
imageName: 'ubuntu-latest'
maximumAllowedFailures: 0 # Maximum allowed failures for a successful build
macOS:
osName: 'macOS'
imageName: 'macOS-latest'
maximumAllowedFailures: 0 # Maximum allowed failures for a successful build
displayName: 'Test net9.0,x64 on'
pool:
vmImage: $(imageName)
steps:
- template: '.build/azure-templates/run-tests-on-os.yml'
parameters:
osName: $(osName)
testTargetFramework: 'net9.0'
vsTestPlatform: 'x64'
testResultsArtifactName: '$(TestResultsArtifactName)'
maximumAllowedFailures: $(maximumAllowedFailures)
dotNetSdkVersion: '$(DotNetSDKVersion)'
- job: Test_net9_0_x86 # Only run if explicitly enabled with RunX86Tests
condition: and(succeeded(), ne(variables['RunTests'], 'false'), eq(variables['RunX86Tests'], 'true'))
strategy:
matrix:
Windows:
osName: 'Windows'
imageName: 'windows-latest'
maximumAllowedFailures: 0 # Maximum allowed failures for a successful build
displayName: 'Test net9.0,x86 on'
pool:
vmImage: $(imageName)
steps:
- template: '.build/azure-templates/run-tests-on-os.yml'
parameters:
osName: $(osName)
testTargetFramework: 'net9.0'
vsTestPlatform: 'x86'
testResultsArtifactName: '$(TestResultsArtifactName)'
maximumAllowedFailures: $(maximumAllowedFailures)
dotNetSdkVersion: '$(DotNetSDKVersion)'
- job: Test_net8_0_x64
condition: and(succeeded(), ne(variables['RunTests'], 'false'))
strategy:
matrix:
Windows:
osName: 'Windows'
imageName: 'windows-latest'
maximumAllowedFailures: 0 # Maximum allowed failures for a successful build
Linux:
osName: 'Linux'
imageName: 'ubuntu-latest'
maximumAllowedFailures: 0 # Maximum allowed failures for a successful build
macOS:
osName: 'macOS'
imageName: 'macOS-latest'
maximumAllowedFailures: 0 # Maximum allowed failures for a successful build
displayName: 'Test net8.0,x64 on'
pool:
vmImage: $(imageName)
steps:
- template: '.build/azure-templates/run-tests-on-os.yml'
parameters:
osName: $(osName)
testTargetFramework: 'net8.0'
vsTestPlatform: 'x64'
testResultsArtifactName: '$(TestResultsArtifactName)'
maximumAllowedFailures: $(maximumAllowedFailures)
dotNetSdkVersion: '$(DotNetSDKVersion)'
- job: Test_net8_0_x86 # Only run if explicitly enabled with RunX86Tests
condition: and(succeeded(), ne(variables['RunTests'], 'false'), eq(variables['RunX86Tests'], 'true'))
strategy:
matrix:
Windows:
osName: 'Windows'
imageName: 'windows-latest'
maximumAllowedFailures: 0 # Maximum allowed failures for a successful build
displayName: 'Test net8.0,x86 on'
pool:
vmImage: $(imageName)
steps:
- template: '.build/azure-templates/run-tests-on-os.yml'
parameters:
osName: $(osName)
testTargetFramework: 'net8.0'
vsTestPlatform: 'x86'
testResultsArtifactName: '$(TestResultsArtifactName)'
maximumAllowedFailures: $(maximumAllowedFailures)
dotNetSdkVersion: '$(DotNetSDKVersion)'
- job: Test_net6_0_x64
condition: and(succeeded(), ne(variables['RunTests'], 'false'))
strategy:
matrix:
Windows:
osName: 'Windows'
imageName: 'windows-latest'
maximumAllowedFailures: 0 # Maximum allowed failures for a successful build
Linux:
osName: 'Linux'
imageName: 'ubuntu-latest'
maximumAllowedFailures: 0 # Maximum allowed failures for a successful build
macOS:
osName: 'macOS'
imageName: 'macOS-latest'
maximumAllowedFailures: 0 # Maximum allowed failures for a successful build
displayName: 'Test net6.0,x64 on'
pool:
vmImage: $(imageName)
steps:
- template: '.build/azure-templates/run-tests-on-os.yml'
parameters:
osName: $(osName)
testTargetFramework: 'net6.0'
vsTestPlatform: 'x64'
testResultsArtifactName: '$(TestResultsArtifactName)'
maximumAllowedFailures: $(maximumAllowedFailures)
dotNetSdkVersion: '$(DotNetSDKVersion)'
- job: Test_net6_0_x86 # Only run if explicitly enabled with RunX86Tests
condition: and(succeeded(), ne(variables['RunTests'], 'false'), eq(variables['RunX86Tests'], 'true'))
strategy:
matrix:
Windows:
osName: 'Windows'
imageName: 'windows-latest'
maximumAllowedFailures: 0 # Maximum allowed failures for a successful build
displayName: 'Test net6.0,x86 on'
pool:
vmImage: $(imageName)
steps:
- template: '.build/azure-templates/run-tests-on-os.yml'
parameters:
osName: $(osName)
testTargetFramework: 'net6.0'
vsTestPlatform: 'x86'
testResultsArtifactName: '$(TestResultsArtifactName)'
maximumAllowedFailures: $(maximumAllowedFailures)
dotNetSdkVersion: '$(DotNetSDKVersion)'
- stage: Publish_Stage
displayName: 'Publish Stage:'
jobs:
- job: Publish
condition: and(succeeded(), ne(variables['ArtifactFeedID'], ''))
pool:
vmImage: 'windows-latest'
steps:
- template: '.build/azure-templates/show-all-environment-variables.yml'
- task: DownloadBuildArtifacts@0
displayName: 'Download Build Artifacts: $(VersionArtifactName)'
inputs:
artifactName: '$(VersionArtifactName)'
downloadPath: '$(Build.ArtifactStagingDirectory)'
# NOTE: We are setting Build.BuildNumber here to the NuGet package version to work around the limitation that
# the version cannot be passed to the Index Sources & Publish Symbols task.
- pwsh: |
$version = Get-Content '$(Build.ArtifactStagingDirectory)/$(VersionArtifactName)/$(PackageVersionFileName)' -Raw
Write-Host "##vso[task.setvariable variable=PackageVersion;]$version"
Write-Host "##vso[build.updatebuildnumber]$version"
displayName: 'Read PackageVersion from File to Build.BuildNumber'
- template: '.build/azure-templates/show-all-environment-variables.yml'
- template: '.build/azure-templates/publish-nuget-packages.yml'
parameters:
artifactFeedID: '$(ArtifactFeedID)'
nugetArtifactName: '$(NuGetArtifactName)'