Skip to content

Commit b68b79a

Browse files
committed
Add MTP validation test suite and packaging improvements
Introduce a comprehensive validation test suite for the Coverlet Microsoft Testing Platform (MTP) extension, including new integration and CLI option tests. Add isolated test infrastructure with sample projects and custom MSBuild props/targets to ensure tests run in a pure MTP environment. Update packaging logic in coverlet.MTP to improve dependency handling and NuGet layout, and adjust build system to better support MTP scenarios. Also includes minor bug fixes and ensures correct local package versioning in tests.
1 parent 02b41f9 commit b68b79a

File tree

21 files changed

+1454
-28
lines changed

21 files changed

+1454
-28
lines changed

Directory.Build.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@
4141
<Deterministic>true</Deterministic>
4242
</PropertyGroup>
4343

44-
<ItemGroup>
44+
<ItemGroup Condition="'$(IsTestProject)' == 'true' And '$(UseMicrosoftTestingPlatformRunner)' != 'true'">
4545
<VSTestLogger Include="trx%3BLogFileName=TestResults-$(TargetFramework)-$(MSBuildProjectName).trx" />
4646
<VSTestLogger Include="html%3BLogFileName=TestResults-$(TargetFramework)-$(MSBuildProjectName).html" />
4747
</ItemGroup>
4848

49-
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
49+
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT' And '$(UseMicrosoftTestingPlatformRunner)' != 'true'">
5050
<VSTestResultsDirectory>$(RepoRoot)artifacts/reports/$(Configuration.ToLowerInvariant())</VSTestResultsDirectory>
5151
<VSTestLogger>@(VSTestLogger)</VSTestLogger>
5252
</PropertyGroup>
5353

54-
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
54+
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' And '$(UseMicrosoftTestingPlatformRunner)' != 'true'">
5555
<VSTestResultsDirectory>$(RepoRoot)artifacts\reports\$(Configuration.ToLowerInvariant())</VSTestResultsDirectory>
5656
<VSTestLogger>@(VSTestLogger)</VSTestLogger>
5757
</PropertyGroup>

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<MicrosoftBuildVersion>17.11.48</MicrosoftBuildVersion> <!-- .NET 8.0 support -->
1111
<MicrosoftCodeAnalysisVersion>4.13.0</MicrosoftCodeAnalysisVersion>
1212
<!-- .NET 8.0 support -->
13-
<NugetPackageVersion>7.0.1</NugetPackageVersion>
13+
<NugetPackageVersion>6.14.0</NugetPackageVersion>
1414
<!-- Test Platform, .NET Test SDK and Object Model -->
1515
<MicrosoftNETTestSdkVersion>18.0.1</MicrosoftNETTestSdkVersion>
1616
<XunitV3Version>3.2.1</XunitV3Version>

src/coverlet.MTP/CoverletExtensionProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static void AddCoverletExtensionProvider(this ITestApplicationBuilder bui
1818
if (ignoreIfNotSupported)
1919
{
2020
#if !NETCOREAPP
21-
coverletExtensionConfiguration.Enable =false;
21+
coverletExtensionConfiguration.Enable = false;
2222
#endif
2323
}
2424

src/coverlet.MTP/buildMultiTargeting/coverlet.MTP.targets

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
1717
</ItemGroup>
1818
<Copy SourceFiles="@(CoverletMTPFiles)" DestinationFolder="$(PublishDir)%(RecursiveDir)" />
1919
</Target>
20-
20+
21+
<!-- Not sure what shall be defined for MTP project -->
22+
<!--<Target Name="SetXPlatDataCollectorPath" BeforeTargets="VSTest">
23+
<PropertyGroup>
24+
<VSTestTestAdapterPath>$(VSTestTestAdapterPath);$(MSBuildThisFileDirectory)</VSTestTestAdapterPath>
25+
</PropertyGroup>
26+
</Target>-->
27+
2128
<PropertyGroup>
2229
<_CoverletSdkNETCoreSdkVersion>$(NETCoreSdkVersion)</_CoverletSdkNETCoreSdkVersion>
2330
<_CoverletSdkNETCoreSdkVersion Condition="$(_CoverletSdkNETCoreSdkVersion.Contains('-'))">$(_CoverletSdkNETCoreSdkVersion.Split('-')[0])</_CoverletSdkNETCoreSdkVersion>

src/coverlet.MTP/coverlet.MTP.csproj

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
4+
<TargetFrameworks>$(NetMinimum);netstandard2.0</TargetFrameworks>
55
<AssemblyTitle>Coverlet.MTP</AssemblyTitle>
66
<DevelopmentDependency>true</DevelopmentDependency>
77
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
88
<ImplicitUsings>enable</ImplicitUsings>
99
<Nullable>enable</Nullable>
10-
<NoWarn>$(NoWarn)</NoWarn>
11-
<EnablePackageValidation>true</EnablePackageValidation>
12-
<IsTestProject>true</IsTestProject>
10+
<NoWarn>$(NoWarn)</NoWarn>
11+
<IncludeBuildOutput>false</IncludeBuildOutput>
12+
13+
<SuppressDependenciesWhenPacking>false</SuppressDependenciesWhenPacking>
14+
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);CopyProjectReferencesToPackage</TargetsForTfmSpecificContentInPackage>
15+
16+
<EnablePackageValidation>false</EnablePackageValidation>
17+
<!--<IsTestProject>true</IsTestProject>-->
1318
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
1419
<IsPackable>true</IsPackable>
15-
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
20+
<NoPackageAnalysis>true</NoPackageAnalysis>
21+
<!-- disable transitive version update and use versions defined in coverlet.core -->
22+
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
1623
</PropertyGroup>
1724

1825
<PropertyGroup>
@@ -46,7 +53,7 @@
4653
</ItemGroup>
4754

4855
<ItemGroup>
49-
<ProjectReference Include="$(MSBuildThisFileDirectory)..\coverlet.core\coverlet.core.csproj" />
56+
<ProjectReference Include="$(MSBuildThisFileDirectory)..\coverlet.core\coverlet.core.csproj" PrivateAssets="all" />
5057
</ItemGroup>
5158

5259
<!-- NuGet package layout -->
@@ -67,4 +74,23 @@
6774
<InternalsVisibleTo Include="coverlet.MTP.unit.tests" Key="0024000004800000940000000602000000240000525341310004000001000100d568d35e41a0829ae24628d27cc43572aa77a3d2f5ac0a6b7554a92d979a72ec0e084c38f83f1ccfc3d26bbeca74131f611a7600a6f218ffc0cbb5758c4e6da50b07fd499d96bdc4e8eb1e10a38231aefd3cde5a69cbade511129588352843950b489b9295a9fb7259b00f18f3a571bdca19b13ccda89cc2a4690f69ee2367b8" />
6875
</ItemGroup>
6976

77+
<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences">
78+
<ItemGroup>
79+
<!-- 1. Main assembly, deps.json, and PDB -->
80+
<TfmSpecificPackageFile Include="$(TargetPath);$(ProjectDepsFilePath);@(DebugSymbolsProjectOutputGroupOutput)" PackagePath="lib\$(TargetFramework)" />
81+
82+
<!-- 2. coverlet.core.dll -->
83+
<TfmSpecificPackageFile Include="%(_ResolvedProjectReferencePaths.Identity)" PackagePath="lib\$(TargetFramework)" />
84+
85+
<!-- 3. ALL transitive dependencies (System.*.dll, etc.) EXCEPT framework references -->
86+
<TfmSpecificPackageFile Include="@(ReferenceCopyLocalPaths)"
87+
Exclude="@(_ResolvedProjectReferencePaths)"
88+
PackagePath="lib\$(TargetFramework)\%(ReferenceCopyLocalPaths.DestinationSubDirectory)"
89+
Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' != 'Microsoft.Testing.Platform' AND '%(ReferenceCopyLocalPaths.NuGetPackageId)' != 'Microsoft.Extensions.DependencyInjection'" />
90+
</ItemGroup>
91+
<!-- Print batches for debug purposes -->
92+
<Message Text="Batch for .nupkg: ReferenceCopyLocalPaths = @(_ReferenceCopyLocalPaths), ReferenceCopyLocalPaths.DestinationSubDirectory = %(_ReferenceCopyLocalPaths.DestinationSubDirectory) Filename = %(_ReferenceCopyLocalPaths.Filename) Extension = %(_ReferenceCopyLocalPaths.Extension)" Importance="High" Condition="'@(_ReferenceCopyLocalPaths)' != ''" />
93+
94+
</Target>
95+
7096
</Project>

src/coverlet.core/coverlet.core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Library</OutputType>
5-
<TargetFrameworks>$(NetMinimum);net472</TargetFrameworks>
5+
<TargetFrameworks>$(NetMinimum);$(NetCurrent);netstandard2.0</TargetFrameworks>
66
<IsPackable>false</IsPackable>
77
<NoWarn>$(NoWarn);IDE0057</NoWarn>
88
</PropertyGroup>

src/coverlet.msbuild.tasks/buildMultiTargeting/coverlet.msbuild.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
</PropertyGroup>
2121
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
2222
<CoverletToolsPath Condition="'$(CoverletToolsPath)' == '' and '$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)..\tasks\net8.0\</CoverletToolsPath>
23-
<CoverletToolsPath Condition="'$(CoverletToolsPath)' == '' and '$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)..\tasks\net472\</CoverletToolsPath>
23+
<CoverletToolsPath Condition="'$(CoverletToolsPath)' == '' and '$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)..\tasks\netstandard2.0\</CoverletToolsPath>
2424
</PropertyGroup>
2525
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
2626
<CoverletToolsPath Condition="'$(CoverletToolsPath)' == '' and '$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)../tasks/net8.0/</CoverletToolsPath>
27-
<!--<CoverletToolsPath Condition="'$(CoverletToolsPath)' == '' and '$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)../tasks/net472/</CoverletToolsPath>-->
27+
<!--<CoverletToolsPath Condition="'$(CoverletToolsPath)' == '' and '$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)../tasks/netstandard2.0/</CoverletToolsPath>-->
2828
</PropertyGroup>
2929
</Project>

src/coverlet.msbuild.tasks/coverlet.msbuild.tasks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Library</OutputType>
5-
<TargetFrameworks>$(NetMinimum);net472</TargetFrameworks>
5+
<TargetFrameworks>$(NetMinimum);netstandard2.0</TargetFrameworks>
66
<AssemblyTitle>coverlet.msbuild.tasks</AssemblyTitle>
77
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
88
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);PackBuildOutputs</TargetsForTfmSpecificContentInPackage>

0 commit comments

Comments
 (0)