-
Notifications
You must be signed in to change notification settings - Fork 6
/
azure-pipelines.yml
121 lines (105 loc) · 3.7 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
trigger:
branches:
include:
- master
- develop
paths:
exclude:
- README.md
- CHANGELOG.md
- CONTRIBUTING.md
pool:
vmImage: 'windows-2019'
variables:
solution: '**.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
major: 6
minor: 0
# creates a counter called cobieversion and seeds it at 0 and then assigns the value to a variable named buildno.
buildNo: $[counter('propertySets', 0)]
name: $(BuildDefinitionName)_$(SourceBranchName)_$(major).$(minor).$(buildNo)
steps:
# Windows script setting up $(packageversion) of the nuget package based on branch
# Master branch
- script: |
echo ##vso[task.setvariable variable=packageversion]$(major).$(minor).$(buildNo)
displayName: 'Setting Master Nuget PackageVersion'
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
- script: |
echo ##vso[task.setvariable variable=packageversion]$(major).$(minor).$(buildNo)-$(Build.SourceBranchName)
displayName: 'Setting Prerelease Nuget PackageVersion'
condition: ne(variables['Build.SourceBranch'], 'refs/heads/master')
# Windows script setting up $(fileversion) used to stamp AssemblyFileVersions.
# By convention we use 'Major.Minor.BuildNo.0' on Master and 'Major.Minor.0.BuildNo' on other branches
# Master branch
- script: |
echo ##vso[task.setvariable variable=fileversion]$(major).$(minor).$(buildNo).0
displayName: 'Setting FileVersion'
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
# Any other branch
- script: |
echo ##vso[task.setvariable variable=fileversion]$(major).$(minor).0.$(buildNo)
displayName: 'Setting Prerelease FileVersion'
condition: ne(variables['Build.SourceBranch'], 'refs/heads/master')
- task: UseDotNet@2
displayName: 'Use .net6'
inputs:
packageType: 'sdk'
version: '6.0.x'
# Version .NET Core project files
# Description - Applies a version to a .NET Core assembly via the .csproj files based on the build number.
# Based on https://github.com/rfennell/AzurePipelines/wiki/Version-Assemblies-and-Packages-Tasks-YAML#versiondotnetcoreassembliestask
- task: VersionDotNetCoreAssemblies@2
displayName: 'Versioning netcore projects'
inputs:
# Required arguments
Path: $(Build.SourcesDirectory)
VersionNumber: $(fileversion)
VersionRegex: \d+\.\d+\.\d+\.\d+
FilenamePattern: .csproj
Field: FileVersion
OutputVersion: OutputedVersion
- task: DotNetCoreCLI@2
displayName: 'Build & Pack'
inputs:
command: 'pack'
packagesToPack: $(solution)
versioningScheme: 'off'
- task: DotNetCoreCLI@2
displayName: 'Test'
inputs:
command: 'test'
projects: '**/*.Tests.csproj'
# Copy artifacts and Publish
- task: CopyFiles@2
displayName: 'Stage artifacts'
inputs:
sourceFolder: '$(Build.BinariesDirectory)'
contents: '**\*.nupkg'
targetFolder: '$(build.artifactstagingdirectory)'
cleanTargetFolder: true
# Publish to master or develop MyGet feed based on the source branch
- task: NuGetCommand@2
displayName: 'Publish to Myget master'
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
inputs:
command: push
nuGetFeedType: external
publishFeedCredentials: 'MyGetMaster'
versioningScheme: byEnvVar
versionEnvVar: packageversion
- task: NuGetCommand@2
displayName: 'Publish to Myget develop'
condition: eq(variables['Build.SourceBranch'], 'refs/heads/develop')
inputs:
command: push
nuGetFeedType: external
publishFeedCredentials: 'MyGetDev'
versioningScheme: byEnvVar
versionEnvVar: packageversion
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact to drop'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
condition: succeededOrFailed()