Skip to content

Commit 5c9d54d

Browse files
EvangelinkCopilot
andcommitted
Point MSTest.Sdk back to the classic sourcegen + engine wiring
Restore the MSTestEngineVersion property and re-add the MSTest.Engine package reference in the NativeAOT engine, referencing both MSTest.Engine and MSTest.SourceGeneration at that version (as in 4.2.3), while keeping the 4.3 packaging/CPM/SDK-layering improvements and report extensions. Since MSTest.Engine and MSTest.SourceGeneration are no longer built from this repo, hardcode the version to the last co-published preview (2.0.0-alpha.26264.3) so consumer projects always resolve a real package instead of an unpublished -dev/-ci build. Also drop the 4.3-only MSTest.TestAdapter reference and the EnableMSTestRunner/IsTestingPlatformApplication property group from the NativeAOT runner. Those were added for the new source generator; with the classic MSTest.Engine they caused a second test framework to be registered ('The test framework adapter factory has already been registered'). Restoring the 4.2 wiring (MSTest.Engine + MSTest.SourceGeneration only) fixes NativeAot_Smoke_Test, verified locally. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 7a12129 commit 5c9d54d

3 files changed

Lines changed: 15 additions & 35 deletions

File tree

src/Package/MSTest.Sdk/MSTest.Sdk.csproj

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@
4646
<Target Name="GenerateTemplates" AfterTargets="PrepareForBuild">
4747
<PropertyGroup>
4848
<!-- https://github.com/dotnet/arcade/blob/cb9979d0e7061c2252f4a3057c20eb72f503cff7/src/Microsoft.DotNet.Arcade.Sdk/tools/Version.BeforeCommonTargets.targets#L111-L114 -->
49-
<_MSTestSourceGenerationPreReleaseVersionLabel>$(MSTestSourceGenerationPreReleaseVersionLabel)</_MSTestSourceGenerationPreReleaseVersionLabel>
50-
<_MSTestSourceGenerationPreReleaseVersionLabel Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(OfficialBuild)' != 'true'">ci</_MSTestSourceGenerationPreReleaseVersionLabel>
51-
<_MSTestSourceGenerationPreReleaseVersionLabel Condition="'$(ContinuousIntegrationBuild)' != 'true' and '$(OfficialBuild)' != 'true'">dev</_MSTestSourceGenerationPreReleaseVersionLabel>
52-
<_MSTestSourceGenerationVersionSuffix>$(_MSTestSourceGenerationPreReleaseVersionLabel)$(_BuildNumberLabels)</_MSTestSourceGenerationVersionSuffix>
53-
<_MSTestSourceGenerationVersion>$(MSTestSourceGenerationVersionPrefix)</_MSTestSourceGenerationVersion>
54-
<_MSTestSourceGenerationVersion Condition="'$(_MSTestSourceGenerationVersionSuffix)' != ''">$(_MSTestSourceGenerationVersion)-$(_MSTestSourceGenerationVersionSuffix)</_MSTestSourceGenerationVersion>
55-
5649
<_MicrosoftTestingExtensionsCtrfReportPreReleaseVersionLabel>$(MicrosoftTestingExtensionsCtrfReportPreReleaseVersionLabel)</_MicrosoftTestingExtensionsCtrfReportPreReleaseVersionLabel>
5750
<_MicrosoftTestingExtensionsCtrfReportPreReleaseVersionLabel Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(OfficialBuild)' != 'true'">ci</_MicrosoftTestingExtensionsCtrfReportPreReleaseVersionLabel>
5851
<_MicrosoftTestingExtensionsCtrfReportPreReleaseVersionLabel Condition="'$(ContinuousIntegrationBuild)' != 'true' and '$(OfficialBuild)' != 'true'">dev</_MicrosoftTestingExtensionsCtrfReportPreReleaseVersionLabel>
@@ -81,7 +74,7 @@
8174
<_MicrosoftTestingExtensionsOpenTelemetryVersion>$(MicrosoftTestingExtensionsOpenTelemetryVersionPrefix)</_MicrosoftTestingExtensionsOpenTelemetryVersion>
8275
<_MicrosoftTestingExtensionsOpenTelemetryVersion Condition="'$(_MicrosoftTestingExtensionsOpenTelemetryVersionSuffix)' != ''">$(_MicrosoftTestingExtensionsOpenTelemetryVersion)-$(_MicrosoftTestingExtensionsOpenTelemetryVersionSuffix)</_MicrosoftTestingExtensionsOpenTelemetryVersion>
8376

84-
<_TemplateProperties>MSTestSourceGenerationVersion=$(_MSTestSourceGenerationVersion);MSTestVersion=$(Version);MicrosoftTestingPlatformVersion=$(Version.Replace('$(VersionPrefix)', '$(TestingPlatformVersionPrefix)'));MicrosoftNETTestSdkVersion=$(MicrosoftNETTestSdkVersion);MicrosoftTestingExtensionsCodeCoverageVersion=$(MicrosoftTestingExtensionsCodeCoverageVersion);MicrosoftPlaywrightVersion=$(MicrosoftPlaywrightVersion);AspireHostingTestingVersion=$(AspireHostingTestingVersion);MicrosoftTestingExtensionsFakesVersion=$(MicrosoftTestingExtensionsFakesVersion);MicrosoftTestingExtensionsCtrfReportVersion=$(_MicrosoftTestingExtensionsCtrfReportVersion);MicrosoftTestingExtensionsJUnitReportVersion=$(_MicrosoftTestingExtensionsJUnitReportVersion);MicrosoftTestingExtensionsGitHubActionsReportVersion=$(_MicrosoftTestingExtensionsGitHubActionsReportVersion);MicrosoftTestingExtensionsOpenTelemetryVersion=$(_MicrosoftTestingExtensionsOpenTelemetryVersion)</_TemplateProperties>
77+
<_TemplateProperties>MSTestVersion=$(Version);MicrosoftTestingPlatformVersion=$(Version.Replace('$(VersionPrefix)', '$(TestingPlatformVersionPrefix)'));MicrosoftNETTestSdkVersion=$(MicrosoftNETTestSdkVersion);MicrosoftTestingExtensionsCodeCoverageVersion=$(MicrosoftTestingExtensionsCodeCoverageVersion);MicrosoftPlaywrightVersion=$(MicrosoftPlaywrightVersion);AspireHostingTestingVersion=$(AspireHostingTestingVersion);MicrosoftTestingExtensionsFakesVersion=$(MicrosoftTestingExtensionsFakesVersion);MicrosoftTestingExtensionsCtrfReportVersion=$(_MicrosoftTestingExtensionsCtrfReportVersion);MicrosoftTestingExtensionsJUnitReportVersion=$(_MicrosoftTestingExtensionsJUnitReportVersion);MicrosoftTestingExtensionsGitHubActionsReportVersion=$(_MicrosoftTestingExtensionsGitHubActionsReportVersion);MicrosoftTestingExtensionsOpenTelemetryVersion=$(_MicrosoftTestingExtensionsOpenTelemetryVersion)</_TemplateProperties>
8578
</PropertyGroup>
8679

8780
<!--

src/Package/MSTest.Sdk/Sdk/Runner/NativeAOT.targets

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,6 @@
33

44
<Import Project="$(MSBuildThisFileDirectory)Common.targets"/>
55

6-
<PropertyGroup Condition=" '$(IsTestApplication)' == 'true' ">
7-
<EnableMSTestRunner>true</EnableMSTestRunner>
8-
9-
<!-- When we are using mstest sdk-style project, we have IsTestingPlatformApplication set to false, thus it's causing issues.
10-
Because we are setting this property based on EnableMSTestRunner which is set to false,
11-
because of the order of import (mstest testadapter props then NativeAOT.targets),
12-
we need to set IsTestingPlatformApplication to true in NativeAOT.targets to fix this issue.
13-
14-
The IsTestingPlatformApplication property is needed for the dotnet test driver to distinguish
15-
if we need to run the test project using the new testing platform. -->
16-
<IsTestingPlatformApplication>true</IsTestingPlatformApplication>
17-
</PropertyGroup>
18-
196
<Target Name="_MSTestSDKValidateFeatures" BeforeTargets="Build">
207
<Error Condition=" '$(EnableAspireTesting)' == 'true' " Text="Aspire MSTest currently doesn't support NativeAOT mode." />
218
<Error Condition=" '$(EnablePlaywright)' == 'true' " Text="Playwright MSTest currently doesn't support NativeAOT mode." />
@@ -43,10 +30,16 @@
4330
<PackageVersion Include="MSTest.TestFramework" Version="$(MSTestVersion)"
4431
Condition=" '$(ManagePackageVersionsCentrally)' == 'true' " />
4532

33+
<PackageReference Include="MSTest.Engine" Sdk="MSTest">
34+
<Version Condition=" '$(ManagePackageVersionsCentrally)' != 'true' ">$(MSTestEngineVersion)</Version>
35+
</PackageReference>
36+
<PackageVersion Include="MSTest.Engine" Version="$(MSTestEngineVersion)"
37+
Condition=" '$(ManagePackageVersionsCentrally)' == 'true' " />
38+
4639
<PackageReference Include="MSTest.SourceGeneration" Sdk="MSTest">
47-
<Version Condition=" '$(ManagePackageVersionsCentrally)' != 'true' ">$(MSTestSourceGenerationVersion)</Version>
40+
<Version Condition=" '$(ManagePackageVersionsCentrally)' != 'true' ">$(MSTestEngineVersion)</Version>
4841
</PackageReference>
49-
<PackageVersion Include="MSTest.SourceGeneration" Version="$(MSTestSourceGenerationVersion)"
42+
<PackageVersion Include="MSTest.SourceGeneration" Version="$(MSTestEngineVersion)"
5043
Condition=" '$(ManagePackageVersionsCentrally)' == 'true' " />
5144
</ItemGroup>
5245

@@ -64,17 +57,6 @@
6457
</PackageReference>
6558
<PackageVersion Include="Microsoft.Testing.Platform" Version="$(MicrosoftTestingPlatformVersion)"
6659
Condition=" '$(EnableMicrosoftTestingPlatform)' == 'true' and '$(ManagePackageVersionsCentrally)' == 'true' " />
67-
68-
<!--
69-
MSTest.TestAdapter is required because it carries MSTestAdapter.PlatformServices.dll which
70-
contains the runtime hook types (ReflectionMetadataHook, SourceGeneratedReflectionDataProvider)
71-
that the MSTest.SourceGeneration analyzer emits calls into.
72-
-->
73-
<PackageReference Include="MSTest.TestAdapter" Sdk="MSTest">
74-
<Version Condition=" '$(ManagePackageVersionsCentrally)' != 'true' ">$(MSTestVersion)</Version>
75-
</PackageReference>
76-
<PackageVersion Include="MSTest.TestAdapter" Version="$(MSTestVersion)"
77-
Condition=" '$(ManagePackageVersionsCentrally)' == 'true' " />
7860
</ItemGroup>
7961

8062
<!-- Extensions -->

src/Package/MSTest.Sdk/Sdk/Sdk.props.template

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@
5151
<MicrosoftTestingExtensionsJUnitReportVersion Condition=" '$(MicrosoftTestingExtensionsJUnitReportVersion)' == '' " >${MicrosoftTestingExtensionsJUnitReportVersion}</MicrosoftTestingExtensionsJUnitReportVersion>
5252
<MicrosoftTestingExtensionsOpenTelemetryVersion Condition=" '$(MicrosoftTestingExtensionsOpenTelemetryVersion)' == '' " >${MicrosoftTestingExtensionsOpenTelemetryVersion}</MicrosoftTestingExtensionsOpenTelemetryVersion>
5353
<MicrosoftTestingPlatformVersion Condition=" '$(MicrosoftTestingPlatformVersion)' == '' " >${MicrosoftTestingPlatformVersion}</MicrosoftTestingPlatformVersion>
54-
<MSTestSourceGenerationVersion Condition=" '$(MSTestSourceGenerationVersion)' == '' ">${MSTestSourceGenerationVersion}</MSTestSourceGenerationVersion>
54+
<!--
55+
MSTest.Engine and MSTest.SourceGeneration are no longer built from this repo. Pin to the last
56+
co-published preview so NativeAOT/source-gen projects resolve a real package on all build kinds
57+
(a computed version would produce an unpublished -dev/-ci suffix). Overridable by the consumer.
58+
-->
59+
<MSTestEngineVersion Condition=" '$(MSTestEngineVersion)' == '' ">2.0.0-alpha.26264.3</MSTestEngineVersion>
5560
<MSTestVersion Condition=" '$(MSTestVersion)' == '' ">${MSTestVersion}</MSTestVersion>
5661
</PropertyGroup>
5762

0 commit comments

Comments
 (0)