-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstandard-azure-pipelines.yml
More file actions
95 lines (83 loc) · 3.3 KB
/
Copy pathstandard-azure-pipelines.yml
File metadata and controls
95 lines (83 loc) · 3.3 KB
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
# Azure DevOps: Restore → Build → Test → Pack (Release), aligned with local dotnet/Cake-style steps.
# SDK version is pinned via global.json at the repository root (UseDotNet@2 useGlobalJson).
# global.json sdk.version must be an explicit version (wildcards are not supported by the task).
trigger:
branches:
include:
- main
variables:
solutionRelativePath: 'src/Example.slnx'
buildConfiguration: 'Release'
jobs:
- job: build
displayName: 'Build and pack'
strategy:
maxParallel: 3
matrix:
windows:
imageName: 'windows-latest'
artifactName: 'nuget-packages-windows'
ubuntu:
imageName: 'ubuntu-latest'
artifactName: 'nuget-packages-ubuntu'
macos:
imageName: 'macOS-latest'
pool:
vmImage: $(imageName)
steps:
- checkout: self
fetchDepth: 0
- task: UseDotNet@2
displayName: 'Install .NET SDK from global.json'
inputs:
packageType: 'sdk'
useGlobalJson: true
workingDirectory: '$(Build.SourcesDirectory)'
includePreviewVersions: true
- powershell: |
$version = "$(Get-Date -Format 'yyyy.M.d').$($env:BUILD_BUILDID)"
Write-Host "PackageVersion=$version"
Write-Host "##vso[task.setvariable variable=PackageVersion]$version"
displayName: 'Setup'
- powershell: |
$ErrorActionPreference = 'Stop'
$sln = Join-Path "$(Build.SourcesDirectory)" "$(solutionRelativePath)"
if (-not (Test-Path -LiteralPath $sln)) { throw "Solution not found: $sln" }
dotnet clean $sln `
/property:Version=$(PackageVersion) `
/property:configuration=$(buildConfiguration)
displayName: 'Clean'
- powershell: |
$ErrorActionPreference = 'Stop'
$sln = Join-Path "$(Build.SourcesDirectory)" "$(solutionRelativePath)"
dotnet restore $sln `
/property:Version=$(PackageVersion) `
/property:configuration=$(buildConfiguration)
displayName: 'Restore'
- powershell: |
$ErrorActionPreference = 'Stop'
$sln = Join-Path "$(Build.SourcesDirectory)" "$(solutionRelativePath)"
dotnet build $sln --no-restore `
/property:Version=$(PackageVersion) `
/property:configuration=$(buildConfiguration)
displayName: 'Build'
- powershell: |
$ErrorActionPreference = 'Stop'
$sln = Join-Path "$(Build.SourcesDirectory)" "$(solutionRelativePath)"
dotnet test $sln --no-build --no-restore `
/property:Version=$(PackageVersion) `
/property:configuration=$(buildConfiguration)
displayName: 'Test'
- powershell: |
$ErrorActionPreference = 'Stop'
$sln = Join-Path "$(Build.SourcesDirectory)" "$(solutionRelativePath)"
dotnet pack $sln --no-build --no-restore `
/property:Version=$(PackageVersion) `
/property:configuration=$(buildConfiguration)
displayName: 'Pack'
- task: PublishPipelineArtifact@1
displayName: 'Publish NuGet packages (bin/Release)'
inputs:
targetPath: '$(Build.SourcesDirectory)/src/Example/bin/$(buildConfiguration)'
artifact: $(artifactName)
condition: succeeded()