Skip to content

Instantly share code, notes, and snippets.

@StefH
Created September 28, 2018 16:20
Show Gist options
  • Save StefH/2b8ba372251a079417604d7185436a49 to your computer and use it in GitHub Desktop.
Save StefH/2b8ba372251a079417604d7185436a49 to your computer and use it in GitHub Desktop.
pool:
vmImage: 'vs2017-win2016'
variables:
buildConfiguration: 'Debug'
buildId: "1$(Build.BuildId)"
steps:
# Print buildId
- script: |
echo "BuildId = $(buildId)"
# Install SonarScanner
- script: |
dotnet tool install --global dotnet-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:"wiremock" /d:sonar.organization="stefh-github" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.login="$(SONAR_TOKEN)" /v:"$(buildId)" /d:sonar.cs.opencover.reportsPaths="**\coverage.opencover.xml"
# Build source, tests and run tests for net452 and netcoreapp2.1 (with coverage)
- script: |
dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration $(buildConfiguration) --framework net452
dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration $(buildConfiguration) --framework netcoreapp2.1 --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
# End SonarScanner
- script: |
%USERPROFILE%\.dotnet\tools\dotnet-sonarscanner end /d:sonar.login="$(SONAR_TOKEN)"
- task: PublishTestResults@2
inputs:
testRunner: VSTest
testResultsFiles: '**/*.trx'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment