-
Notifications
You must be signed in to change notification settings - Fork 11
/
azure-pipelines.yml
193 lines (168 loc) · 6.27 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
190
191
192
193
# ASP.NET Core
# Build and test ASP.NET Core web applications targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/vsts/pipelines/languages/dotnet-core
pool:
vmImage: 'windows-latest'
trigger:
branches:
include:
- main
- refs/tags/*
schedules:
- cron: '0 0 * * *'
displayName: Daily Build
always: true
branches:
include:
- main
variables:
buildConfiguration: 'Release'
# Define the GitVersion environment variables so they can be used in all tasks.
GitVersion.SemVer: ''
steps:
# if the pipeline is set up to use a shallow git fetch mode the GitVersion Execute task will fail.
# It is required to use fetchDepth: 0
- checkout: self
fetchDepth: 0
- task: gitversion/[email protected]
displayName: Install GitVersion
inputs:
versionSpec: '6.x'
- task: gitversion/[email protected]
displayName: Determine Version
# https://dotnet.microsoft.com/download/dotnet/9.0
- task: UseDotNet@2
displayName: Install .Net 9.0.100
inputs:
packageType: 'sdk'
version: '9.0.100'
- script: |
echo buildConfiguration: $(buildConfiguration)
echo GitVersion.SemVer: $(GitVersion.SemVer)
displayName: 'Print Variables'
- script: |
npm install
workingDirectory: $(Build.SourcesDirectory)/src/Opw.PineBlog.RazorPages
displayName: 'Install packages (npm)'
- task: DotNetCoreCLI@2
displayName: Build
inputs:
projects: '**/*.csproj'
arguments: '--configuration $(buildConfiguration) /p:Version=$(GitVersion.SemVer)'
- task: DotNetCoreCLI@2
displayName: Test
inputs:
command: test
projects: |
**/tests/*.Tests/*.csproj
**/tests/*.IntegrationTests/*.csproj
arguments: '--configuration $(buildConfiguration) --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Include="[Opw.*]*" /p:Exclude="[*.Tests]*%2c[*.*Tests]*%2c[*.Testing]*%2c[*.Sample.*]*"'
# Release: triggered by a version tag
- task: DotNetCoreCLI@2
displayName: Publish
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
inputs:
command: publish
publishWebProjects: false
projects: |
**/samples/Opw.PineBlog.Sample/*.csproj
arguments: '--configuration $(buildConfiguration) --framework net9.0 --output $(build.artifactstagingdirectory) /p:Version=$(GitVersion.SemVer) --no-build'
zipAfterPublish: false
# Delete the "Areas" folder, this should not be deployed
- task: DeleteFiles@1
displayName: Publish Cleanup
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
inputs:
SourceFolder: $(build.artifactstagingdirectory)\Opw.PineBlog.Sample
Contents: 'Areas'
- task: DotNetCoreCLI@2
displayName: NuGet Pack Opw.PineBlog.Core
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
inputs:
command: pack
packagesToPack: '**/Opw.PineBlog.Core.csproj'
nobuild: true
versioningScheme: byEnvVar
versionEnvVar: 'GitVersion.SemVer'
- task: DotNetCoreCLI@2
displayName: NuGet Pack Opw.PineBlog.RazorPages
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
inputs:
command: pack
packagesToPack: '**/Opw.PineBlog.RazorPages.csproj'
nobuild: true
versioningScheme: byEnvVar
versionEnvVar: 'GitVersion.SemVer'
- task: DotNetCoreCLI@2
displayName: NuGet Pack Opw.PineBlog.EntityFrameworkCore
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
inputs:
command: pack
packagesToPack: '**/Opw.PineBlog.EntityFrameworkCore.csproj'
nobuild: true
versioningScheme: byEnvVar
versionEnvVar: 'GitVersion.SemVer'
- task: DotNetCoreCLI@2
displayName: NuGet Pack Opw.PineBlog.MongoDb
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
inputs:
command: pack
packagesToPack: '**/Opw.PineBlog.MongoDb.csproj'
nobuild: true
versioningScheme: byEnvVar
versionEnvVar: 'GitVersion.SemVer'
# TODO: when Opw.PineBlog.GitDb is ready start publishing this nuget package
#- task: DotNetCoreCLI@2
# displayName: NuGet Pack Opw.PineBlog.GitDb
# condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
# inputs:
# command: pack
# packagesToPack: '**/Opw.PineBlog.GitDb.csproj'
# nobuild: true
# versioningScheme: byEnvVar
# versionEnvVar: 'GitVersion.SemVer'
- task: DotNetCoreCLI@2
displayName: NuGet Pack Opw.PineBlog
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
inputs:
command: pack
packagesToPack: '**/Opw.PineBlog.csproj'
nobuild: true
versioningScheme: byEnvVar
versionEnvVar: 'GitVersion.SemVer'
- task: NuGetCommand@2
displayName: NuGet Push
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
inputs:
command: push
nuGetFeedType: external
publishFeedCredentials: NuGet
versioningScheme: byEnvVar
versionEnvVar: 'GitVersion.SemVer'
- task: GithubRelease@1
displayName: Create GitHub Release
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
inputs:
gitHubConnection: 'github.com'
repositoryName: '$(Build.Repository.Name)'
action: 'create'
target: '$(Build.SourceVersion)'
tagSource: 'gitTag'
tag: '$(GitVersion.SemVer)'
- task: reportgenerator@5
displayName: 'Generate Code Coverage Report'
inputs:
reports: '$(Build.SourcesDirectory)/**/coverage*cobertura.xml'
targetdir: '$(build.artifactstagingdirectory)/coverage/'
# PublishCodeCoverageResults v2 does not support publishing of the code coverage reports created by Report generator task.
- task: PublishCodeCoverageResults@1
displayName: 'Publish Code Coverage Results'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(build.artifactstagingdirectory)/coverage/cobertura.xml'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifacts'
condition: always()
inputs:
PathtoPublish: $(build.artifactstagingdirectory)