Skip to content

Migrate Microsoft.NET.Sdk.Publish.Tasks.Tests to MSTest.Sdk on MTP - #54854

Merged
Evangelink merged 9 commits into
dotnet:mainfrom
Evangelink:evangelink/mstest-mtp-publishtasks-tests
Jun 23, 2026
Merged

Evangelink merged 9 commits into
dotnet:mainfrom
Evangelink:evangelink/mstest-mtp-publishtasks-tests

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Migrates Microsoft.NET.Sdk.Publish.Tasks.Tests from xUnit to MSTest.Sdk on Microsoft.Testing.Platform (MTP), switching its test-framework reference to Microsoft.NET.TestFramework.MSTest.

Part of the SDK acceptance-test xUnit-->MSTest migration. Depends on #54845 (the Microsoft.NET.TestFramework.MSTest foundation) which must merge first. Compiles clean locally for all target frameworks.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 18, 2026 12:55
@Evangelink
Evangelink requested a review from vijayrkn as a code owner June 18, 2026 12:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR continues the SDK acceptance-test xUnit→MSTest migration by converting Microsoft.NET.Sdk.Publish.Tasks.Tests to run on MSTest.Sdk (on Microsoft.Testing.Platform) and switching the project to use the MSTest-flavored test framework (Microsoft.NET.TestFramework.MSTest). It also adds MSTest equivalents of several custom conditional test attributes and an MSTest base class for ASP.NET SDK tests.

Changes:

  • Switch Microsoft.NET.Sdk.Publish.Tasks.Tests to MSTest.Sdk and update its framework reference to Microsoft.NET.TestFramework.MSTest.
  • Convert Publish tasks tests from xUnit attributes/assertions to MSTest ([TestClass], [TestMethod], [DataRow], [DynamicData], MSTest asserts).
  • Add MSTest implementations of conditional test attributes and AspNetSdkTest in Microsoft.NET.TestFramework.MSTest.
Show a summary per file
File Description
test/Microsoft.NET.TestFramework.MSTest/ConditionalTestAttributes.cs Adds MSTest equivalents for custom conditional attributes used across SDK tests.
test/Microsoft.NET.TestFramework.MSTest/AspNetSdkTest.cs Introduces MSTest AspNetSdkTest base class mirroring the xUnit version.
test/Microsoft.NET.Sdk.Publish.Tasks.Tests/Microsoft.NET.Sdk.Publish.Tasks.Tests.csproj Migrates the test project to MSTest.Sdk and switches test framework reference.
test/Microsoft.NET.Sdk.Publish.Tasks.Tests/WebJobsCommandGeneratorTests.cs Converts xUnit theory to MSTest data-driven test.
test/Microsoft.NET.Sdk.Publish.Tasks.Tests/WebConfigTransformTests.cs Converts xUnit facts/theories to MSTest methods with DataRow/DynamicData and MSTest asserts.
test/Microsoft.NET.Sdk.Publish.Tasks.Tests/WebConfigTelemetryTests.cs Converts xUnit theory to MSTest and updates asserts.
test/Microsoft.NET.Sdk.Publish.Tasks.Tests/Tasks/ZipDeploy/ZipDeploymentStatusTests.cs Converts xUnit theories to MSTest DataRow tests and updates asserts.
test/Microsoft.NET.Sdk.Publish.Tasks.Tests/Tasks/ZipDeploy/ZipDeployerTaskTests.cs Converts xUnit fact/theories to MSTest and updates asserts.
test/Microsoft.NET.Sdk.Publish.Tasks.Tests/Tasks/TransformXmlTests.cs Converts xUnit facts to MSTest and uses MSTest collection asserts (HasCount/IsEmpty).
test/Microsoft.NET.Sdk.Publish.Tasks.Tests/Tasks/TransformWebConfigTests.cs Converts xUnit theory/fact to MSTest and updates asserts.
test/Microsoft.NET.Sdk.Publish.Tasks.Tests/Tasks/TransformAppSettingsTests.cs Converts xUnit theories to MSTest DynamicData and updates asserts.
test/Microsoft.NET.Sdk.Publish.Tasks.Tests/Tasks/OneDeploy/OneDeployTests.WebJob.cs Converts xUnit theories to MSTest DataRow tests and updates asserts.
test/Microsoft.NET.Sdk.Publish.Tasks.Tests/Tasks/OneDeploy/OneDeployTests.cs Converts xUnit facts/theories to MSTest and updates asserts.
test/Microsoft.NET.Sdk.Publish.Tasks.Tests/Tasks/OneDeploy/OneDeployStatusServiceTests.cs Converts xUnit facts/theories to MSTest and updates asserts.
test/Microsoft.NET.Sdk.Publish.Tasks.Tests/Tasks/OneDeploy/CreatePackageFileTests.cs Converts xUnit facts/theories to MSTest and updates asserts.
test/Microsoft.NET.Sdk.Publish.Tasks.Tests/Tasks/GenerateEnvTransformTests.cs Converts xUnit theories/facts to MSTest and updates asserts.
test/Microsoft.NET.Sdk.Publish.Tasks.Tests/Tasks/GenerateEFSQLScriptsTests.cs Converts xUnit member-data theory to MSTest DynamicData (NET472-only).
test/Microsoft.NET.Sdk.Publish.Tasks.Tests/EnvironmentHelperTests.cs Converts xUnit theory to MSTest DataRow test and updates asserts.
test/Microsoft.NET.Sdk.Publish.Tasks.Tests/EndToEnd/ProcessWrapper.cs Replaces xUnit output helper usage with MSTest TestContext logging.
test/Microsoft.NET.Sdk.Publish.Tasks.Tests/EndToEnd/FolderPublish50.cs Converts xUnit tests to MSTest and updates logging to use TestContext.
test/Microsoft.NET.Sdk.Publish.Tasks.Tests/AppSettingsTransformTests.cs Converts xUnit facts/theories to MSTest DataRow/DynamicData and updates asserts.

Copilot's findings

  • Files reviewed: 21/21 changed files
  • Comments generated: 4

Comment thread test/Microsoft.NET.Sdk.Publish.Tasks.Tests/WebJobsCommandGeneratorTests.cs Outdated
Comment thread test/Microsoft.NET.TestFramework.MSTest/AspNetSdkTest.cs Outdated
Comment thread test/Microsoft.NET.TestFramework.MSTest/AspNetSdkTest.cs Outdated
@Evangelink
Evangelink enabled auto-merge June 19, 2026 11:14
Evangelink and others added 2 commits June 19, 2026 15:57
Under MSTest method-level parallelism the data-driven test mutates the
process-wide DOTNET_CLI_TELEMETRY_OPTOUT variable concurrently, producing
nondeterministic Assert.AreEqual failures. Mark the class [DoNotParallelize].

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
MTP (MSTest.Sdk) test apps were always invoked via 'dotnet exec <target>'.
For .NET Framework targets TargetPath is the native '.exe', which has no
runtimeconfig.json, so 'dotnet exec' treats it as a self-contained .NET Core
app and fails with 'hostpolicy.dll ... not found' (exit -2147450749). Launch
the .exe directly for .NETFramework while keeping 'dotnet exec <dll>' for
.NET (Core).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

Copy link
Copy Markdown
Member Author

/ba-g blazor test crashing, it's unrelated to this PR

@Evangelink

Copy link
Copy Markdown
Member Author

/ba-g #54823

Evangelink and others added 3 commits June 22, 2026 18:17
… build

Microsoft.DotNet.Cli.Utils.Tests is an MSTest.Sdk project, but
TransientSdkResolutionErrorDetectorTests.cs was added still using xUnit [Fact],
so the test build fails with CS0246 'Fact'/'FactAttribute' on main and on every
PR built against it (including this one). Add [TestClass] and convert the five
[Fact] methods to [TestMethod]; MSTest.Sdk provides the MSTest namespace and
FluentAssertions as implicit global usings, so no using changes are needed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

Copy link
Copy Markdown
Member Author

/ba-g #54927

@Evangelink
Evangelink merged commit d23b440 into dotnet:main Jun 23, 2026
23 of 25 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants