-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
98 lines (94 loc) · 2.83 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
trigger:
branches:
include: [ '*' ]
exclude: [ 'refs/tags/*' ]
variables:
BuildConfiguration: Release
DotNetCoreVersionPrevious: 8.x
DotNetCoreVersionLatest: 9.x
parameters:
- name: publishPackages
displayName: "Publish NuGet packages"
type: boolean
default: false
stages:
- stage: BuildAndTest
jobs:
- job: BuildAndTest
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: self
fetchDepth: 0
persistCredentials: 'true'
clean: true
# Install the desired .NET SDK.
- task: UseDotNet@2
displayName: 'Acquire .NET $(DotNetCoreVersionPrevious) SDK'
inputs:
packageType: 'sdk'
version: $(DotNetCoreVersionPrevious)
includePreviewVersions: false
- task: UseDotNet@2
displayName: 'Acquire .NET $(DotNetCoreVersionLatest) SDK'
inputs:
packageType: 'sdk'
version: $(DotNetCoreVersionLatest)
includePreviewVersions: false
# Build all projects.
- task: DotNetCoreCLI@2
displayName: 'Build Projects'
inputs:
projects: '**/*.csproj'
arguments: '--configuration $(BuildConfiguration)'
# Run all available tests.
- task: DotNetCoreCLI@2
displayName: 'Execute Tests'
inputs:
command: test
projects: '**/*Tests/*.csproj'
arguments: '--configuration $(BuildConfiguration)'
nobuild: true
# Create the NuGet packages.
- task: DotNetCoreCLI@2
displayName: 'Pack Packages'
inputs:
command: 'pack'
packagesToPack: 'src/**/*.csproj'
nobuild: true
verbosityPack: Minimal
includesymbols: false
# Copy created NuGet packages to the builds artifacts directory.
- task: PublishBuildArtifacts@1
displayName: 'Publish Package Artifacts'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'packages'
publishLocation: 'Container'
- stage: PublishPackages
dependsOn: BuildAndTest
# Only publish packages for main branch.
condition: and(succeeded('BuildAndTest'), eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(${{ parameters.publishPackages }}, true))
jobs:
- job: PublishPackages
pool:
vmImage: 'ubuntu-latest'
steps:
# Download the created packages.
- task: DownloadBuildArtifacts@0
displayName: 'Download NuGet Packges'
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'packages'
downloadPath: '$(System.ArtifactsDirectory)'
# Publish the NuGet packages to the package feed.
- task: DotNetCoreCLI@2
displayName: Push Nuget Package
inputs:
command: custom
custom: nuget
arguments: >
push $(System.ArtifactsDirectory)/**/*.nupkg
-s https://api.nuget.org/v3/index.json
-k $(NuGetApiKey)