-
Notifications
You must be signed in to change notification settings - Fork 3
/
azure-pipelines.yml
80 lines (70 loc) · 2.5 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
trigger:
- develop
- master
- feature*
- release*
- bug*
pool:
name: Hosted Windows 2019 with VS2019
variables:
- name: DOTNET_CLI_TELEMETRY_OPTOUT
value: 1
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
value: 1
- name: solution
value: 'Z85e.sln'
- name: buildPlatform
value: 'x64'
- name: buildConfiguration
value: 'Release'
- group: Z85e
steps:
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: 'restore'
projects: $(solution)
feedsToUse: 'select'
nugetConfigPath: nuget.config
- script: dotnet build --configuration $(buildConfiguration) --no-restore
displayName: 'dotnet build $(buildConfiguration)'
# Run tests and recored coverage.
# Recording coverage is done using coverlet and can be enabled for each test project by adding the nuget package 'coverlet.msbuild'
# when the package is not referenced, no coverage is recorded but the tests are run normally.
# It looks like this task will suffix the arguments with '--results-directory $(Agent.TempDirectory)'
- task: DotNetCoreCLI@2
displayName: 'Test and calculate code coverage'
inputs:
command: test
projects: '$(solution)'
arguments: '-c $(buildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --no-restore --no-build --logger trx'
# Make Azure DevOps aware of the coverage results.
# When there are no test coverage results, this task will generate a warning.
# Because there is only one test project, we do not need to merge the results.
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage to devops'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '**/coverage.cobertura.xml'
# Install codecov as a dotnet tool
- task: DotNetCoreCLI@2
displayName: 'Install codecov as dotnet tool'
inputs:
command: custom
custom: tool
arguments: 'install Codecov.Tool --tool-path $(Build.SourcesDirectory)/tools'
# Publish test coverage results to the codecov account
# $(CodeCovToken) is placed in the DevOps Library 'Z85e' as a secret value.
- script: $(Build.SourcesDirectory)/tools/codecov.exe -f "src/Z85e.Test/coverage.cobertura.xml" -t $(CodeCovToken)
displayName: 'Publish code coverage to CodeCov.io'
# Create nuget packages (nupkg, and snupkg)
- task: DotNetCoreCLI@2
displayName: 'dotnet pack'
inputs:
command: pack
configuration: '$(BuildConfiguration)'
nobuild: false
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'