1+ # ASP.NET Core (.NET Framework)
2+ # Build and test ASP.NET Core projects targeting the full .NET Framework.
3+ # Add steps that publish symbols, save build artifacts, and more:
4+ # https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
5+
6+ trigger :
7+ - master
8+
9+ pool :
10+ vmImage : ' windows-latest'
11+
12+ variables :
13+ solution : ' **/*.sln'
14+ buildPlatform : ' Any CPU'
15+ buildConfiguration : ' Release'
16+ NUGET_PACKAGES : $(Pipeline.Workspace)/.nuget/packages
17+
18+ steps :
19+ - task : DotNetCoreCLI@2
20+ displayName : Restore nuget packages
21+ inputs :
22+ command : restore
23+ projects : ' **/*.csproj'
24+ arguments : ' --locked-mode'
25+ workingDirectory : $(Build.SourcesDirectory)
26+
27+ - task : DotNetCoreCLI@2
28+ displayName : Build
29+ inputs :
30+ command : build
31+ projects : ' $(solution)'
32+ arguments : ' --configuration $(buildConfiguration)'
33+
34+ # Run all tests with "/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura" to generate the code coverage file
35+ - task : DotNetCoreCLI@2
36+ displayName : Test
37+ inputs :
38+ command : test
39+ arguments : ' --configuration $(BuildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura'
40+ projects : ' $(solution)'
41+ nobuild : true
42+ continueOnError : true
43+
44+ # Generate the report using ReportGenerator (https://github.com/danielpalme/ReportGenerator)
45+ # First install the tool on the machine, then run it
46+ - script : |
47+ dotnet tool install -g dotnet-reportgenerator-globaltool
48+ reportgenerator -reports:$(Build.SourcesDirectory)/tests/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/CodeCoverage -reporttypes:Cobertura
49+ displayName : Create Code coverage report
50+
51+ # Publish the code coverage result (summary and web site)
52+ # The summary allows to view the coverage percentage in the summary tab
53+ # The web site allows to view which lines are covered directly in Azure Pipeline
54+ - task : PublishCodeCoverageResults@1
55+ displayName : ' Publish code coverage'
56+ inputs :
57+ codeCoverageTool : Cobertura
58+ summaryFileLocation : ' $(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml'
59+ reportDirectory : ' $(Build.SourcesDirectory)/CodeCoverage'
60+ pathToSources : ' $(Build.SourcesDirectory)'
61+
62+ - task : PublishTestResults@2
63+ inputs :
64+ testResultsFormat : ' VSTest'
65+ testResultsFiles : ' **/TEST-*.xml'
66+ mergeTestResults : true
67+ failTaskOnFailedTests : true
68+
69+ - task : DotNetCoreCLI@2
70+ inputs :
71+ command : publish
72+ publishWebProjects : True
73+ arguments : ' --configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
74+ zipAfterPublish : True
75+
76+ - task : PublishBuildArtifacts@1
77+ inputs :
78+ PathtoPublish : ' $(Build.ArtifactStagingDirectory)'
79+ ArtifactName : ' drop'
80+ publishLocation : ' Container'
0 commit comments