@@ -5,35 +5,60 @@ environment:
55 secure : nXDnbkmLZ0yeSj623ZeiGO+be5JhivxxrgiJ9lgHLVH/PKoI52UO2Kt6965QAAM+
66 NUGET_API_KEY :
77 secure : CbJ7DaN2P9YI9zVjNR98Ld3gM0RXqxo91R0wLUO4PcTAVj65mF48vzMNr7JnMppM
8+ SONARQUBE_ORGANIZATION : dotarj-github
9+ SONARQUBE_TOKEN :
10+ secure : zmYFq7/1VpOvb/E+voAXfsRIEuekDH0gpKA89h1V4nH0TqCgKxb8G7ZVPt9mpsBB
11+ SONARQUBE_GITHUB_TOKEN :
12+ secure : R0EXcWv91EY6EVoT7NmIPXxU6ZfqIK0Rhbe2uT9pboQQT99XuVQENS1JE+izE7bI
813
914image : Visual Studio 2017
1015
1116skip_tags : false
1217
18+ branches :
19+ only :
20+ - master
21+
1322configuration : Release
1423
1524init :
1625- ps : |
17- If ($($env:APPVEYOR_REPO_TAG) -eq "true") {
18- $env:RELEASE_VERSION = $env:APPVEYOR_REPO_TAG_NAME
19- }
20- else {
21- $env:RELEASE_VERSION = "0.0.0-ci.sha.$($env:APPVEYOR_REPO_COMMIT.Substring(0, 7)).build.$env:APPVEYOR_BUILD_NUMBER"
22- }
26+ function Execute-Action {
27+ param($description, $action)
2328
24- Update-AppveyorBuild -Version $env:RELEASE_VERSION
29+ Write-Host (Get-Date).ToString("hh:mm:ss.fff") "STARTED $description" -ForegroundColor Magenta
30+
31+ &$action
32+
33+ Write-Host (Get-Date).ToString("hh:mm:ss.fff") "FINISHED $description" -ForegroundColor Magenta
34+
35+ if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
36+ }
2537
26- install :
2738 - ps : |
28- Write-Host "STARTED installing code coverage tools" -ForegroundColor Magenta
39+ Execute-Action "updating build version" {
40+ If ($env:APPVEYOR_REPO_TAG -eq $true) {
41+ $env:RELEASE_VERSION = $env:APPVEYOR_REPO_TAG_NAME
42+ }
43+ else {
44+ $env:RELEASE_VERSION = "0.0.0-ci.sha.$($env:APPVEYOR_REPO_COMMIT.Substring(0, 7)).build.$env:APPVEYOR_BUILD_NUMBER"
45+ }
2946
30- choco install opencover.portable
47+ Write-Host "Build version:" $env:RELEASE_VERSION -ForegroundColor White
3148
32- choco install codecov
49+ Update-AppveyorBuild -Version $env:RELEASE_VERSION
50+ }
3351
34- Write-Host "FINISHED installing code coverage tools" -ForegroundColor Magenta
52+ - ps : |
53+ Execute-Action "updating path variable" {
54+ $env:PATH = $env:PATH + ";C:/Program Files (x86)/Microsoft SDKs/Windows/v10.0A/bin/NETFX 4.7 Tools"
55+ }
3556
36- if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
57+ install :
58+ - ps : |
59+ Execute-Action "installing tools" {
60+ choco install codecov msbuild-sonarqube-runner opencover.portable
61+ }
3762
3863dotnet_csproj :
3964 patch : true
@@ -42,84 +67,69 @@ dotnet_csproj:
4267
4368before_build :
4469- ps : |
45- Write-Host "STARTED restoring project dependencies" -ForegroundColor Magenta
46-
47- dotnet restore -v m
48-
49- Write-Host "FINISHED restoring project dependencies" -ForegroundColor Magenta
70+ Execute-Action "restoring project dependencies" {
71+ dotnet restore -v m
72+ }
5073
51- if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
74+ - ps : |
75+ Execute-Action "beginning code analysis" {
76+ if ($env:APPVEYOR_PULL_REQUEST_NUMBER) {
77+ MSBuild.SonarQube.Runner.exe begin /o:$env:SONARQUBE_ORGANIZATION /k:$env:APPVEYOR_PROJECT_NAME /v:$env:APPVEYOR_BUILD_VERSION /d:sonar.host.url=https://sonarcloud.io /d:sonar.login=$env:SONARQUBE_TOKEN /d:sonar.cs.opencover.reportsPaths=coverage.xml /d:sonar.coverage.exclusions=**/*Tests.cs /d:sonar.github.pullRequest=$env:APPVEYOR_PULL_REQUEST_NUMBER /d:sonar.github.repository=$env:APPVEYOR_REPO_NAME /d:sonar.github.oauth=$env:SONARQUBE_GITHUB_TOKEN
78+ }
79+ else {
80+ MSBuild.SonarQube.Runner.exe begin /o:$env:SONARQUBE_ORGANIZATION /k:$env:APPVEYOR_PROJECT_NAME /v:$env:APPVEYOR_BUILD_VERSION /d:sonar.host.url=https://sonarcloud.io /d:sonar.login=$env:SONARQUBE_TOKEN /d:sonar.cs.opencover.reportsPaths=coverage.xml /d:sonar.coverage.exclusions=**/*Tests.cs
81+ }
82+ }
5283
5384build_script :
5485- ps : |
55- Write-Host "STARTED building project" -ForegroundColor Magenta
56-
57- dotnet build -c $env:CONFIGURATION --no-restore -v m
58-
59- Write-Host "FINISHED building project" -ForegroundColor Magenta
60-
61- if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
86+ Execute-Action "building project" {
87+ dotnet build -c $env:CONFIGURATION --no-restore -v m
88+ }
6289
6390after_build :
6491- ps : |
65- If ($($ env:VERIFY_STRONG_NAME) -eq " true" ) {
66- Write-Host "STARTED verifying strong name" -ForegroundColor Magenta
67-
68- $sn = "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7 Tools\ sn.exe"
92+ If ($env:VERIFY_STRONG_NAME -eq $ true) {
93+ Execute-Action " verifying strong name" {
94+ foreach ($assembly in ls "src/$env:APPVEYOR_PROJECT_NAME/bin/$env:CONFIGURATION/*/$env:APPVEYOR_PROJECT_NAME.dll") {
95+ sn.exe -vf $assembly
6996
70- foreach ($assembly in ls "src\$env:APPVEYOR_PROJECT_NAME\bin\$env:CONFIGURATION\*\$env:APPVEYOR_PROJECT_NAME.dll") {
71- &$sn -vf $assembly
72-
73- if ($LastExitCode -ne 0) { Break }
97+ if ($LastExitCode -ne 0) { Break }
98+ }
7499 }
75-
76- Write-Host "FINISHED verifying strong name" -ForegroundColor Magenta
77-
78- if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
79100 }
80101
81102 - ps : |
82- Write-Host "STARTED creating NuGet package" -ForegroundColor Magenta
83-
84- dotnet pack src\$env:APPVEYOR_PROJECT_NAME -c $env:CONFIGURATION --no-restore --no-build --include-symbols --output ..\..\artifacts -v m
85-
86- Write-Host "FINISHED creating NuGet package" -ForegroundColor Magenta
87-
88- if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
103+ Execute-Action "creating NuGet package" {
104+ dotnet pack src/$env:APPVEYOR_PROJECT_NAME -c $env:CONFIGURATION --no-restore --no-build --include-symbols --output ../../artifacts -v m
105+ }
89106
90107test_script :
91108- ps : |
92- Write-Host "STARTED running unit tests" -ForegroundColor Magenta
93-
94- dotnet test test\$env:APPVEYOR_PROJECT_NAME.Tests -c $env:CONFIGURATION --no-restore --no-build -v m
95-
96- Write-Host "FINISHED running unit tests" -ForegroundColor Magenta
97-
98- if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
109+ Execute-Action "running unit tests" {
110+ dotnet test test/$env:APPVEYOR_PROJECT_NAME.Tests -c $env:CONFIGURATION --no-restore --no-build -v m
111+ }
99112
100113after_test :
101114- ps : |
102- Write-Host "STARTED generating code coverage report" -ForegroundColor Magenta
103-
104- dotnet build -c $env:CONFIGURATION --no-restore -v m /p:codecov=true
105-
106- OpenCover.Console.exe -target:"$env:XUNIT20\xunit.console.x86.exe" -targetargs:"test\$env:APPVEYOR_PROJECT_NAME.Tests\bin\$env:CONFIGURATION\net471\$env:APPVEYOR_PROJECT_NAME.Tests.dll -noshadow" -register:user -filter:"+[*]* -[$env:APPVEYOR_PROJECT_NAME.Tests]* -[$env:APPVEYOR_PROJECT_NAME.Samples]*" -hideskipped:All -output:".\coverage.xml"
107-
108- Write-Host "FINISHED generating code coverage report" -ForegroundColor Magenta
115+ Execute-Action "generating code coverage report" {
116+ dotnet build -c $env:CONFIGURATION --no-restore -v m /p:codecov=true
109117
110- if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
118+ OpenCover.Console.exe -target:"$env:XUNIT20/xunit.console.x86.exe" -targetargs:"test/$env:APPVEYOR_PROJECT_NAME.Tests/bin/$env:CONFIGURATION/net471/$env:APPVEYOR_PROJECT_NAME.Tests.dll -noshadow" -register:user -filter:"+[*]* -[$env:APPVEYOR_PROJECT_NAME.Tests]* -[$env:APPVEYOR_PROJECT_NAME.Samples]*" -hideskipped:All -output:"./coverage.xml"
119+ }
111120
112121 - ps : |
113- Write-Host "STARTED uploading code coverage report" -ForegroundColor Magenta
114-
115- codecov -f coverage.xml
116-
117- Write-Host "FINISHED uploading code coverage report" -ForegroundColor Magenta
122+ Execute-Action "uploading code coverage report" {
123+ codecov.exe -f coverage.xml
124+ }
118125
119- if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
126+ - ps : |
127+ Execute-Action "ending code analysis" {
128+ MSBuild.SonarQube.Runner.exe end /d:sonar.login=$env:SONARQUBE_TOKEN
129+ }
120130
121131artifacts :
122- - path : artifacts\ *.nupkg
132+ - path : artifacts/ *.nupkg
123133 name : NuGet
124134
125135deploy :
0 commit comments