-
Notifications
You must be signed in to change notification settings - Fork 3
/
azure-pipelines.yml
114 lines (98 loc) · 3.6 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
# Yaml Pipeline Tasks for reference: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/index?view=vsts
trigger:
branches:
include:
- master
- develop
paths:
exclude:
- README.md
- CHANGELOG.md
- CONTRIBUTING.md
pool:
vmImage: 'windows-2022'
variables:
solution: '*.sln'
BuildConfiguration: 'Release'
BuildPlatform: 'Any CPU'
major: 6
minor: 2
# creates a named counter and seeds it at 100 and then assigns the value to a variable named buildNo.
buildNo: $[counter('winversioncounter', 100)]
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 Nuget PackageVersion'
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
# Any other branch
- 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: DotNetCoreCLI@2
displayName: 'Restoring packages'
inputs:
command: 'restore'
projects: '**/*.csproj'
feedsToUse: 'config'
nugetConfigPath: 'nuget.config'
externalFeedCredentials: 'MyGetDev, MyGetMaster'
- task: DotNetCoreCLI@2
displayName: 'Build and Packing'
inputs:
command: 'pack'
packagesToPack: '**/*.csproj'
versioningScheme: 'off'
- task: CopyFiles@2
displayName: 'Copy Nuget packages to: $(build.artifactstagingdirectory)'
inputs:
SourceFolder: '$(build.sourcesdirectory)'
Contents: '**\bin\$(BuildConfiguration)\*.nupkg'
TargetFolder: '$(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
- task: NuGetCommand@2
displayName: 'Pushing to Master'
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg'
nuGetFeedType: 'external'
publishFeedCredentials: 'MyGetMaster'
versioningScheme: byEnvVar
versionEnvVar: packageVersion
- task: NuGetCommand@2
displayName: 'Pushing to MyGet Dev'
condition: ne(variables['Build.SourceBranch'], 'refs/heads/master')
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg'
nuGetFeedType: 'external'
publishFeedCredentials: 'MyGetDev'
versioningScheme: byEnvVar
versionEnvVar: packageVersion
- task: NuGetCommand@2
displayName: 'Pushing to Develop'
condition: ne(variables['Build.SourceBranch'], 'refs/heads/master')
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: '2591d379-784d-4b57-88f5-a932c93cbffd'