forked from SonarSource/sonar-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines-external.yml
77 lines (65 loc) · 2.83 KB
/
azure-pipelines-external.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
pool: '.Net Bubble - GCP'
variables:
- group: sonar-dotnet-variables
- group: sonarsource-build-variables
- name: MsBuildPath
value: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild.exe'
- name: vsVersion
value: '17.0'
stages:
- stage: buildAndTests
displayName: Build
jobs:
- job: runUnitTestsJob
displayName: 'Build and tests:'
steps:
- task: NuGetToolInstaller@1
displayName: "Install NuGet"
- powershell: |
dotnet --list-sdks
dotnet --version
displayName: 'List dotnet versions and current version'
- script: '"${{ variables.MsBuildPath }}" /t:restore /p:RestoreLockedMode=true /p:RestoreConfigFile="analyzers\NuGet.Config" $(solution)'
displayName: "NuGet Restore"
- powershell: |
# Calculate the file path
$versionFilePath = "$env:BUILD_SOURCESDIRECTORY\scripts\version\Version.props"
Write-Host "Reading the Sonar project version from '${versionFilePath}' ..."
# Read the version from the file
[xml]$versionProps = Get-Content "$versionFilePath"
$sonarProjectVersion = $versionProps.Project.PropertyGroup.MainVersion
Write-Host "Sonar project version is '${sonarProjectVersion}'"
# Set the variable to it can be used by other tasks
Write-Host "##vso[task.setvariable variable=SONAR_PROJECT_VERSION;]$sonarProjectVersion"
displayName: 'Read Sonar project version from the versions.props file'
- task: VSBuild@1
displayName: 'Set BranchName, Sha1 and BuildNumber properties from Azure pipeline variables'
inputs:
solution: scripts/version/ChangeVersion.proj
msbuildArgs: '/p:Sha1=$(Build.SourceVersion) /p:BranchName=$(Build.SourceBranchName) /p:BuildNumber=$(Build.BuildId) /p:BuildConfiguration=$(BuildConfiguration)'
vsVersion: $(vsVersion)
- task: VSBuild@1
displayName: 'Build SonarAnalyzer solution'
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
msbuildArgs: '/p:DeployExtension=false /p:Sha1=$(Build.SourceVersion) /p:BuildNumber=$(Build.BuildId)'
vsVersion: $(vsVersion)
- task: VSTest@2
displayName: ".NET UTs"
inputs:
testAssemblyVer2: |
**\$(BuildConfiguration)\**\*.UnitTest.dll
!**\obj\**
runInParallel: true
runTestsInIsolation: true
codeCoverageEnabled: true
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
rerunFailedTests: false
- task: PowerShell@2
displayName: '.NET ITs'
inputs:
filePath: 'analyzers/its/regression-test.ps1'
workingDirectory: 'analyzers/its'