Skip to content

Commit f501a12

Browse files
Update build configuration to windows-2022 + add code coverage
1 parent 286f49c commit f501a12

File tree

2 files changed

+43
-26
lines changed

2 files changed

+43
-26
lines changed

Tests/HttpClient.Caching.Tests/HttpClient.Caching.Tests.csproj

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,22 @@
1010
<NeutralLanguage>en</NeutralLanguage>
1111
</PropertyGroup>
1212

13-
<ItemGroup>
14-
<PackageReference Include="FluentAssertions" Version="6.1.0" />
15-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
16-
<PackageReference Include="Moq" Version="4.16.1" />
17-
<PackageReference Include="xunit" Version="2.4.1" />
18-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
19-
<PrivateAssets>all</PrivateAssets>
20-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
21-
</PackageReference>
22-
</ItemGroup>
13+
<ItemGroup>
14+
<PackageReference Include="coverlet.msbuild" Version="3.1.2">
15+
<PrivateAssets>all</PrivateAssets>
16+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
17+
</PackageReference>
18+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
19+
<PackageReference Include="ncrontab" Version="3.3.1" />
20+
<PackageReference Include="ObjectDumper.NET" Version="3.3.20" />
21+
<PackageReference Include="xunit" Version="2.4.1" />
22+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
23+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
24+
<PrivateAssets>all</PrivateAssets>
25+
</PackageReference>
26+
<PackageReference Include="Moq.AutoMock" Version="3.3.0" />
27+
<PackageReference Include="FluentAssertions" Version="6.6.0" />
28+
</ItemGroup>
2329

2430
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
2531
<Reference Include="System.Net.Http" />

build.yml

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
name: $[format('{0}', variables['buildName'])]
88

99
pool:
10-
vmImage: 'windows-2019'
10+
vmImage: 'windows-2022'
1111

1212
trigger:
1313
branches:
@@ -19,9 +19,7 @@ trigger:
1919

2020
paths:
2121
exclude:
22-
- README.md
23-
- Images/*
24-
- Samples/*
22+
- Docs/*
2523

2624
variables:
2725
solution: 'HttpClient.Caching.sln'
@@ -69,31 +67,37 @@ steps:
6967
FailOnWarning: false
7068
DisableTelemetry: false'
7169

72-
7370
- task: NuGetToolInstaller@0
74-
displayName: 'Use NuGet 5.x'
71+
displayName: 'Use NuGet 6.x'
7572
inputs:
76-
versionSpec: 5.x
73+
versionSpec: 6.x
7774

78-
- task: NuGetCommand@2
75+
- task: DotNetCoreCLI@2
7976
displayName: 'NuGet restore'
8077
inputs:
81-
restoreSolution: '$(solution)'
78+
command: restore
79+
projects: '$(solution)'
8280

83-
- task: VSBuild@1
81+
- task: DotNetCoreCLI@2
8482
displayName: 'Build solution'
8583
inputs:
86-
solution: '$(solution)'
87-
msbuildArgs: ''
88-
platform: '$(BuildPlatform)'
89-
configuration: '$(BuildConfiguration)'
90-
84+
projects: '$(solution)'
85+
arguments: '--no-restore --configuration $(buildConfiguration)'
86+
9187
- task: DotNetCoreCLI@2
9288
displayName: 'Run UnitTests'
9389
inputs:
9490
command: test
9591
projects: '**/*.Tests.csproj'
96-
arguments: '--no-restore --no-build --configuration $(buildConfiguration)'
92+
arguments: '--no-restore --no-build --configuration $(buildConfiguration) /p:CollectCoverage=true /p:Exclude="[Microsoft*]*%2C[Mono*]*%2C[xunit*]*%2C[*.Testdata]*" /p:CoverletOutput=UnitTests.coverage.cobertura.xml /p:MergeWith=$(Build.SourcesDirectory)/Tests/CoverletOutput/coverage.json /p:CoverletOutputFormat=cobertura'
93+
94+
- task: Palmmedia.reportgenerator.reportgenerator-build-release-task.reportgenerator@4
95+
displayName: 'Create Code Coverage Report'
96+
inputs:
97+
reports: '$(Build.SourcesDirectory)/Tests/**/*.coverage.cobertura*.xml'
98+
targetdir: '$(Build.SourcesDirectory)/CodeCoverage'
99+
reporttypes: 'Cobertura'
100+
assemblyfilters: '-xunit*'
97101

98102
- task: DotNetCoreCLI@2
99103
displayName: 'Pack HttpClient.Caching'
@@ -113,6 +117,13 @@ steps:
113117
**\bin\*.nupkg
114118
115119
TargetFolder: '$(Build.ArtifactStagingDirectory)'
120+
121+
- task: PublishCodeCoverageResults@1
122+
displayName: 'Publish code coverage'
123+
inputs:
124+
codeCoverageTool: Cobertura
125+
summaryFileLocation: '$(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml'
126+
reportDirectory: '$(Build.SourcesDirectory)/CodeCoverage'
116127

117128
- task: PublishBuildArtifacts@1
118129
displayName: 'Publish Artifact: drop'

0 commit comments

Comments
 (0)