-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
77 lines (68 loc) · 2.43 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
trigger:
branches:
include:
- refs/heads/*
exclude:
- refs/tags/*
variables:
hasCodeCoverage: false
shouldPushPrerelease: true
buildConfiguration: 'Release'
buildProjects: '**/*.csproj'
testProjects: '**/*.Test*.csproj'
system_accesstoken: $(System.AccessToken)
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
isMaster: $[eq(variables['Build.SourceBranch'], 'refs/heads/master')]
isPrerelease: $[and(ne(variables['isMaster'],'true'), not(startswith(variables['Build.SourceBranch'], 'refs/pull')))]
branchIsOfInterest: $[or(eq(variables['isMaster'],'true'), and(eq(variables['shouldPushPrerelease'],'true'), eq(variables['isPrerelease'],'true')))]
steps:
- checkout: self
clean: true
persistCredentials: true
- task: DotNetCoreCLI@2
displayName: Restore Packages
inputs:
command: restore
projects: $(buildProjects)
noCache: true
verbosityRestore: Normal
- task: DotNetCoreCLI@2
displayName: Build Projects
inputs:
projects: $(buildProjects)
arguments: '-c $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: Test Projects
inputs:
command: test
projects: $(testProjects)
publishTestResults: true
arguments: '--no-build -c $(buildConfiguration) /p:Exclude="[xunit*]*"'
- powershell: |
if((Test-Path -Path "$(Build.SourcesDirectory)/TestResults/Reports") -and ((gci -Path "$(Build.SourcesDirectory)/TestResults/Reports" -Filter "*.xml" | measure).Count -gt 0))
{
Write-Host "##vso[task.setvariable variable=hasCodeCoverage;]true"
}
displayName: 'Count code coverage results'
- task: PublishCodeCoverageResults@1
displayName: 'Publish Code Coverage Results'
condition: and(succeeded(), eq(variables['hasCodeCoverage'],'true'))
inputs:
codeCoverageTool: cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/TestResults/Reports/Cobertura.xml'
reportDirectory: '$(Build.SourcesDirectory)/TestResults/Reports'
additionalCodeCoverageFiles: '$(Build.SourcesDirectory)/TestResults/*.xml'
failIfCoverageEmpty: true
- task: CopyFiles@2
displayName: Copy Packages To Artifacts
inputs:
SourceFolder: 'artifacts/nupkgs'
Contents: '*.nupkg'
TargetFolder: '$(Build.ArtifactStagingDirectory)/nupkgs/'
CleanTargetFolder: true
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)/nupkgs'
artifactName: 'nupkgs'
publishLocation: Container