|
1 | 1 | <Project Sdk="Microsoft.NET.Sdk"> |
2 | 2 |
|
3 | 3 | <PropertyGroup> |
| 4 | + <OutputType>Exe</OutputType> |
4 | 5 | <TargetFramework>net8.0</TargetFramework> |
5 | 6 | <Nullable>enable</Nullable> |
6 | 7 | </PropertyGroup> |
7 | 8 |
|
8 | 9 | <ItemGroup> |
9 | 10 | <PackageReference Include="AwesomeAssertions" Version="9.4.0" /> |
10 | | - <PackageReference Include="coverlet.collector" Version="10.0.1" PrivateAssets="all" /> |
11 | | - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.7.0" /> |
| 11 | + <!-- Starting with version 18.5.1, coverage is empty when ContinuousIntegrationBuild is set to true --> |
| 12 | + <PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" Version="[18.4.1, 18.5.1)" /> |
| 13 | + <PackageReference Include="Microsoft.Testing.Extensions.TrxReport" Version="2.2.1" /> |
12 | 14 | <PackageReference Include="PublicApiGenerator" Version="11.5.4" /> |
13 | 15 | <PackageReference Include="ReportGenerator" Version="5.5.10" PrivateAssets="all" /> |
14 | 16 | <PackageReference Include="Serilog" Version="4.3.1" /> |
15 | 17 | <PackageReference Include="Serilog.Enrichers.Environment" Version="3.0.1" /> |
16 | 18 | <PackageReference Include="Serilog.Enrichers.Thread" Version="4.0.0" /> |
17 | 19 | <PackageReference Include="Verify.XunitV3" Version="31.20.0" /> |
18 | | - <PackageReference Include="xunit.v3.mtp-off" Version="3.2.2" /> |
19 | | - <PackageReference Include="xunit.runner.visualstudio" Version="3.1.5" PrivateAssets="all" /> |
| 20 | + <PackageReference Include="xunit.v3.mtp-v2" Version="3.2.2" /> |
20 | 21 | </ItemGroup> |
21 | 22 |
|
22 | | - <ItemGroup> |
23 | | - <VSTestLogger Include="trx%3BLogFileName=$(MSBuildProjectName).trx" Visible="false" /> |
24 | | - <VSTestLogger Include="html%3BLogFileName=$(MSBuildProjectName).html" Visible="false" /> |
25 | | - </ItemGroup> |
| 23 | + <PropertyGroup Label="xUnit"> |
| 24 | + <!-- UseMicrosoftTestingPlatformRunner is required for JetBrains Rider to see the tests when discovery is configured to use metadata (Settings | Build, Execution, Deployment | Unit Testing | xUnit.net) --> |
| 25 | + <UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner> |
| 26 | + <!-- TestingPlatformDotnetTestSupport is ignored with the .NET 10 SDK but is required for older SDKs --> |
| 27 | + <TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport> |
| 28 | + </PropertyGroup> |
26 | 29 |
|
27 | 30 | <PropertyGroup Label="Coverage"> |
| 31 | + <TestResultsDirectory>$([System.IO.Path]::Combine($(ArtifactsPath),'test-results',$(TargetFramework)))</TestResultsDirectory> |
28 | 32 | <CoverageReportDirectory>$([System.IO.Path]::Combine($(ArtifactsPath),'coverage',$(TargetFramework)))</CoverageReportDirectory> |
29 | | - <VSTestResultsDirectory>$([System.IO.Path]::Combine($(ArtifactsPath),'test-results',$(TargetFramework)))</VSTestResultsDirectory> |
30 | | - <VSTestCollect>XPlat Code Coverage%3BExcludeByAttribute=GeneratedCodeAttribute</VSTestCollect> |
31 | | - <VSTestLogger>@(VSTestLogger)</VSTestLogger> |
| 33 | + <CoverageReportFile>$([System.IO.Path]::Combine($(CoverageReportDirectory),'$(MSBuildProjectName).cobertura.xml'))</CoverageReportFile> |
| 34 | + <CoverageSettingsFile>$([System.IO.Path]::GetFullPath($([System.IO.Path]::Combine($(MSBuildThisFileDirectory), 'coverage.xml'))))</CoverageSettingsFile> |
| 35 | + <ArgsCoverage>--coverage --coverage-output-format cobertura --coverage-output $(CoverageReportFile) --coverage-settings $(CoverageSettingsFile)</ArgsCoverage> |
| 36 | + <ArgsTrx>--report-trx --report-trx-filename $(MSBuildProjectName).trx --results-directory $(TestResultsDirectory)</ArgsTrx> |
| 37 | + <TestingPlatformCommandLineArguments>$(ArgsCoverage) $(ArgsTrx)</TestingPlatformCommandLineArguments> |
32 | 38 | </PropertyGroup> |
33 | 39 |
|
34 | 40 | <Target Name="GenerateCoverageReports" AfterTargets="VSTest" Condition="$(TargetFramework) != ''"> |
35 | 41 | <ItemGroup> |
36 | | - <CoverageReport Include="$(VSTestResultsDirectory)/*/coverage.cobertura.xml" /> |
| 42 | + <CoverageReport Include="$(CoverageReportDirectory)/*.cobertura.xml" /> |
37 | 43 | </ItemGroup> |
38 | 44 | <ReportGenerator ReportFiles="@(CoverageReport)" TargetDirectory="$(CoverageReportDirectory)" ReportTypes="HtmlInline;TextSummary" /> |
39 | 45 | <Move SourceFiles="@(CoverageReport)" DestinationFolder="$(CoverageReportDirectory)" /> |
40 | 46 | </Target> |
41 | 47 |
|
42 | | - <!-- Because of https://github.com/microsoft/vstest/issues/2334 and https://github.com/microsoft/vstest/issues/2378 --> |
| 48 | + <!-- Because of https://github.com/microsoft/vstest/issues/2334 --> |
43 | 49 | <Target Name="RemoveSpuriousDirectories" AfterTargets="GenerateCoverageReports" Condition="$(TargetFramework) != ''"> |
44 | 50 | <ItemGroup> |
45 | | - <SpuriousDirectory Include="$([System.IO.Directory]::GetDirectories($(VSTestResultsDirectory)))" /> |
| 51 | + <SpuriousDirectory Include="$([System.IO.Directory]::GetDirectories($(TestResultsDirectory)))" /> |
46 | 52 | </ItemGroup> |
47 | 53 | <RemoveDir Directories="@(SpuriousDirectory)" /> |
48 | 54 | </Target> |
|
0 commit comments