-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathazure-pipelines.yml
108 lines (93 loc) · 3.86 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
pool:
vmImage: 'windows-2022'
variables:
Prerelease: 'ci'
buildType: 'azure-pipelines-ci'
buildId: "$(Build.BuildId)"
buildProjects: '**/src/**/+(XPath2|XPath2.Extensions).csproj'
steps:
# Print buildId
- script: |
echo "BuildId = $(buildId)"
displayName: 'Print buildId'
- task: PowerShell@2
displayName: "Use JDK17 by default"
inputs:
targetType: 'inline'
script: |
$jdkPath = $env:JAVA_HOME_17_X64
Write-Host "##vso[task.setvariable variable=JAVA_HOME]$jdkPath"
# Install SonarScanner
- script: |
dotnet tool install --global dotnet-sonarscanner
displayName: Install SonarScanner
# Begin SonarScanner
# See also
# - https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools, else you get this error: `Since you just installed the .NET Core SDK, you will need to reopen the Command Prompt window before running the tool you installed.`
# - https://github.com/dotnet/cli/issues/8368
# - https://github.com/Microsoft/vsts-tasks/issues/8291
#
- script: |
%USERPROFILE%\.dotnet\tools\dotnet-sonarscanner begin /k:"StefH_XPath2.Net" /o:"stefh-github" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.login="$(SONAR_TOKEN)" /v:"$(buildId)" /d:sonar.cs.opencover.reportsPaths="**\coverage.net8.0.opencover.xml"
displayName: Begin SonarScanner
- task: DotNetCoreCLI@2
displayName: Build Debug [net452]
inputs:
command: 'build'
arguments: /p:Configuration=Debug --framework net452
projects: $(buildProjects)
- task: DotNetCoreCLI@2
displayName: Build Debug [netstandard2.0]
inputs:
command: 'build'
arguments: /p:Configuration=Debug --framework netstandard2.0
projects: $(buildProjects)
- task: DotNetCoreCLI@2
displayName: Build Debug [netstandard2.1]
inputs:
command: 'build'
arguments: /p:Configuration=Debug --framework netstandard2.1
projects: $(buildProjects)
# Build tests and run tests for net452 and net6.0 and net8.0 (with coverage)
- script: |
dotnet test ./tests/XPath2.Tests/XPath2.Tests.csproj --configuration Debug --framework net452
dotnet test ./tests/XPath2.Tests/XPath2.Tests.csproj --configuration Debug --framework net6.0
dotnet test ./tests/XPath2.Tests/XPath2.Tests.csproj --configuration Debug --framework net8.0 --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
displayName: 'Build tests and run tests for net452 and net6.0 and net8.0 (with coverage)'
# End SonarScanner
- script: |
%USERPROFILE%\.dotnet\tools\dotnet-sonarscanner end /d:sonar.login="$(SONAR_TOKEN)"
displayName: End SonarScanner
- task: PublishTestResults@2
inputs:
testRunner: VSTest
testResultsFiles: '**/*.trx'
# Based on https://whereslou.com/2018/09/versioning-and-publishing-nuget-packages-automatically-using-azure-devops-pipelines/
- task: DotNetCoreCLI@2
displayName: Build Projects in Release configuration
inputs:
command: 'build'
arguments: /p:Configuration=Release
projects: $(buildProjects)
- task: DotNetCoreCLI@2
displayName: Pack
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests
inputs:
command: pack
configuration: 'Release'
packagesToPack: $(buildProjects)
nobuild: true
packDirectory: '$(Build.ArtifactStagingDirectory)/packages'
verbosityPack: 'normal'
- task: PublishBuildArtifacts@1
displayName: Publish Artifacts
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
- task: DotNetCoreCLI@2
displayName: Push to MyGet
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests
inputs:
command: custom
custom: nuget
arguments: push $(Build.ArtifactStagingDirectory)\packages\*.nupkg -n -s https://www.myget.org/F/xpath2/api/v3/index.json --no-service-endpoint --api-key $(MyGetKey)