forked from xBimTeam/XbimEssentials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
189 lines (151 loc) · 7.9 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# .NET Desktop
# 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
- develop
paths:
exclude:
- README.md
- CHANGELOG.md
- CONTRIBUTING.md
pool:
vmImage: 'windows-2022'
variables:
buildConfiguration: 'Release'
major: 5
minor: 1
# creates a counter called versioncounter and seeds it at 100 and then assigns the value to a variable named buildNo.
buildNo: $[counter('versioncounter', 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 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: NuGetToolInstaller@1
displayName: 'Install Nuget'
# 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 $(fileversion)'
inputs:
# Required arguments
Path: $(Build.SourcesDirectory)
VersionNumber: $(fileversion)
VersionRegex: \d+\.\d+\.\d+\.\d+
FilenamePattern: .csproj
Field: FileVersion
OutputVersion: OutputedVersion
# Unit tests
- task: DotNetCoreCLI@2
displayName: 'dotnet test $(buildConfiguration)'
inputs:
command: test
projects: '**/*Tests/*.csproj'
arguments: '--configuration $(buildConfiguration) --collect "Code coverage"'
# So we can pick up packages we build
- script: nuget sources add -Name local -Source $(Build.BinariesDirectory)
displayName: 'Setting local nuget source'
# xBIM Common
- script: dotnet pack Xbim.Common/Xbim.Common.csproj -c Release -o $(Build.BinariesDirectory) /p:PackageVersion=$(packageversion)
displayName: 'Xbim.Common - packing'
# xBIM Ifc4
- script: dotnet remove Xbim.Ifc4\Xbim.Ifc4.csproj reference ..\Xbim.Common\Xbim.Common.csproj
displayName: 'Xbim.IFC4 - remove project references'
- script: dotnet add Xbim.Ifc4\Xbim.Ifc4.csproj package Xbim.Common -s $(Build.BinariesDirectory) -v $(packageversion)
displayName: 'Xbim.IFC4 - adding package references'
- script: dotnet pack Xbim.Ifc4/Xbim.Ifc4.csproj -c Release -o $(Build.BinariesDirectory) /p:PackageVersion=$(packageversion)
displayName: 'Xbim.IFC4 - packing'
# Ifc2x3
- script: dotnet remove Xbim.Ifc2x3\Xbim.Ifc2x3.csproj reference ..\Xbim.Common\Xbim.Common.csproj ..\Xbim.Ifc4\Xbim.Ifc4.csproj
displayName: 'Xbim.IFC2x3 - remove project references'
- script: dotnet add Xbim.Ifc2x3\Xbim.Ifc2x3.csproj package Xbim.Ifc4 -s $(Build.BinariesDirectory) -v $(packageversion)
displayName: 'Xbim.IFC2x3 - adding package references'
- script: dotnet pack Xbim.Ifc2x3/Xbim.Ifc2x3.csproj -c Release -o $(Build.BinariesDirectory) /p:PackageVersion=$(packageversion)
displayName: 'Xbim.IFC2x3 - packing'
# Memory Model
- script: dotnet remove Xbim.IO.MemoryModel\Xbim.IO.MemoryModel.csproj reference ..\Xbim.Common\Xbim.Common.csproj ..\Xbim.Ifc2x3\Xbim.Ifc2x3.csproj ..\Xbim.Ifc4\Xbim.Ifc4.csproj
displayName: 'Xbim.IO.MemoryModel - remove project references'
- script: dotnet add Xbim.IO.MemoryModel\Xbim.IO.MemoryModel.csproj package Xbim.Ifc2x3 -s $(Build.BinariesDirectory) -v $(packageversion)
displayName: 'Xbim.IO.MemoryModel - add package references'
- script: dotnet pack Xbim.IO.MemoryModel\Xbim.IO.MemoryModel.csproj -c Release -o $(Build.BinariesDirectory) /p:PackageVersion=$(packageversion)
displayName: 'Xbim.IO.MemoryModel - packing'
# Esent Model
- script: dotnet remove Xbim.IO.Esent\Xbim.IO.Esent.csproj reference ..\Xbim.Common\Xbim.Common.csproj ..\Xbim.IO.MemoryModel\Xbim.IO.MemoryModel.csproj
displayName: 'Xbim.IO.Esent - remove project references'
- script: dotnet add Xbim.IO.Esent\Xbim.IO.Esent.csproj package Xbim.IO.MemoryModel -s $(Build.BinariesDirectory) -v $(packageversion)
displayName: 'Xbim.IO.Esent - add package references'
- script: dotnet pack Xbim.IO.Esent\Xbim.IO.Esent.csproj -c Release -o $(Build.BinariesDirectory) /p:PackageVersion=$(packageversion)
displayName: 'Xbim.IO.Esent - packing'
# Ifc
- script: dotnet remove Xbim.Ifc\Xbim.Ifc.csproj reference ..\Xbim.Common\Xbim.Common.csproj ..\Xbim.Ifc2x3\Xbim.Ifc2x3.csproj ..\Xbim.Ifc4\Xbim.Ifc4.csproj ..\Xbim.IO.MemoryModel\Xbim.IO.MemoryModel.csproj
displayName: 'Xbim.IFC - remove project references'
- script: dotnet add Xbim.Ifc\Xbim.Ifc.csproj package Xbim.IO.MemoryModel -s $(Build.BinariesDirectory) -v $(packageversion)
displayName: 'Xbim.IFC - add project reference'
- script: dotnet pack Xbim.Ifc\Xbim.Ifc.csproj -c Release -o $(Build.BinariesDirectory) /p:PackageVersion=$(packageversion)
displayName: 'Xbim.IFC - packing'
# Tessellator
- script: dotnet remove Xbim.Tessellator\Xbim.Tessellator.csproj reference ..\Xbim.Common\Xbim.Common.csproj ..\Xbim.Ifc2x3\Xbim.Ifc2x3.csproj ..\Xbim.Ifc4\Xbim.Ifc4.csproj
displayName: 'Xbim.Tessellator - remove project references'
- script: dotnet add Xbim.Tessellator\Xbim.Tessellator.csproj package Xbim.Ifc2x3 -s $(Build.BinariesDirectory) -v $(packageversion)
displayName: 'Xbim.Tessellator - add package references'
- script: dotnet pack Xbim.Tessellator\Xbim.Tessellator.csproj -c Release -o $(Build.BinariesDirectory) /p:PackageVersion=$(packageversion)
displayName: 'Xbim.Tessellator - packing'
# Essentials meta package
- powershell: |
((Get-Content -path Xbim.Essentials.tmpl -Raw) -replace '{{version}}','$(packageversion)') | Set-Content -Path Xbim.Essentials.nuspec
displayName: 'Xbim.Essentials - Setting packageversion $(packageversion)'
- script: nuget pack Xbim.Essentials.nuspec -OutputDirectory $(Build.BinariesDirectory)
displayName: 'Xbim.Essentials - packing'
# Copy artifacts and Publish
- task: CopyFiles@2
displayName: 'Copy to 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 artifacts'