-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
145 lines (140 loc) · 5.12 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
# .NET Desktop/.NET Standard libraries
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net
trigger:
branches:
include:
- master
- refs/tags/*
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
feed: 'optiblast'
dotnetCoreVersion: 3.1.x
stages:
- stage: Build
displayName: Build .dll's
jobs:
- job: Build
displayName: DotNetCore build
steps:
- task: UseDotNet@2
displayName: Use .NET Core sdk
inputs:
packageType: sdk
version: '$(dotnetCoreVersion)'
installationPath: '$(Agent.ToolsDirectory)/dotnet'
- task: PowerShell@2
displayName: 'Install paket CLI and dependencies'
inputs:
targetType: inline
script: |
dotnet tool install -g paket
paket restore
paket install
- task: UseDotNet@2
displayName: Use .NET Core sdk
inputs:
packageType: sdk
version: '$(dotnetCoreVersion)'
installationPath: '$(Agent.ToolsDirectory)/dotnet'
# Restore from an feed scoped feed in the same feed
- task: NuGetCommand@2
name: Restore
displayName: Nuget Restore
inputs:
command: restore
feedsToUse: config
nugetConfigPath: nuget.config
vstsFeed: '$(feed)'
restoreSolution: '$(solution)'
- task: DotNetCoreCLI@2
displayName: Run tests
inputs:
command: test
arguments: '--no-restore'
- task: DotNetCoreCLI@2
displayName: Build .sln solution
inputs:
command: build
configuration: '$(buildConfiguration)'
projects: '$(solution)'
arguments: '--no-restore'
- stage: GeneratePackage
displayName: Create Nuget .nupkg package
dependsOn: Build
jobs:
- job: Pack
displayName: Package the component
steps:
# Create a ENV variable with latest Git tag
- task: PowerShell@2
displayName: Set last tag to environment variable
inputs:
targetType: 'inline'
script: |
$VERSION_TAG = git describe --tags (git rev-list --tags --max-count=1)
Write-Host("##vso[task.setvariable variable=VERSION_TAG]$VERSION_TAG")
Write-Host("##vso[build.addbuildtag]$VERSION_TAG")
Write-Host($VERSION_TAG)
# Package a project
- task: NuGetCommand@2
displayName: Generate the .nupkg
inputs:
command: pack
versioningScheme: byEnvVar
versionEnvVar: '$(VERSION_TAG)'
configuration: '$(buildConfiguration)'
packagesToPack: '$(libProject)/*.csproj'
packDestination: '$(Build.ArtifactStagingDirectory)'
includeSymbols: true
# Publish the generated file like a pipeline artifact
- task: PublishBuildArtifacts@1
displayName: Publish .nupkg like a pipeline artifact
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: '$(libProject).$(VERSION_TAG)'
- stage: Publish
displayName: Publish package to Azure Devops Artifacts feed
condition: startsWith(variables['build.sourceBranch'], 'refs/tags/')
jobs:
- job: AuthenticateAndPublish
displayName: Publish to Azure Artifacts
steps:
# Restore from an feed scoped feed in the same feed
- task: NuGetCommand@2
name: Restore
displayName: Nuget Restore
inputs:
command: restore
feedsToUse: config
nugetConfigPath: 'nuget.config'
vstsFeed: '$(feed)'
restoreSolution: '$(solution)'
- task: NuGetAuthenticate@0
name: Authenticate
displayName: NuGet Authentication on private feed
# PS: Azure Artifacts don't supports ".snupkg" symbols file
- task: PublishSymbols@2
displayName: Publish the symbols *.pdb to Azure Artifacts
inputs:
SearchPattern: '$(libProject)/bin/**/*.pdb'
SymbolServerType: TeamServices
- task: NuGetCommand@2
name: PublishNupkg
displayName: Publish the .nupkg
inputs:
command: push
versioningScheme: byEnvVar
versionEnvVar: '$(VERSION_TAG)'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;$(Build.ArtifactStagingDirectory)/**/*.snupkg'
feedsToUse: config
nuGetFeedType: internal
nugetConfigPath: '$(Build.WorkingDirectory)/nuget.config'
publishVstsFeed: '$(feed)'
allowPackageConflicts: true
includeNuGetOrg: false