Skip to content

Conversation

@MichaelSimons
Copy link
Member

@MichaelSimons MichaelSimons commented Feb 12, 2026

The RunTestAsTool concept was necessary when there was separate dotnet/sdk and dotnet/installer repos. The installer ran several of the sdk tests using this mechanism. Now that the repos have been consolidated, this infrastructure is no longer necessary. Removing it cleans up the infrastructure and removes an entire leg from CI (TestAsTools). This infrastructure was requiring workarounds for the xunit v3 upgrade

@MichaelSimons MichaelSimons marked this pull request as ready for review February 12, 2026 22:22
Copilot AI review requested due to automatic review settings February 12, 2026 22:22
@MichaelSimons MichaelSimons requested a review from a team February 12, 2026 22:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Removes the legacy “RunTestsAsTool/TestAsTool” infrastructure (originally used for running SDK tests from the old installer repo) and cleans up associated MSBuild and pipeline wiring, with some related test-context simplification.

Changes:

  • Removes CanRunTestAsTool usage from test/benchmark projects and deletes the TestAsTool MSBuild target + OverrideTest.targets.
  • Drops the AzDO “TestAsTools” job category and removes runTestsAsTool pipeline plumbing.
  • Simplifies SdkTestContext.Initialize path inference for test assets and execution directories.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/trustedroots.Tests/trustedroots.Tests.csproj Removes obsolete CanRunTestAsTool property.
test/dotnet.Tests/dotnet.Tests.csproj Removes obsolete CanRunTestAsTool property.
test/dotnet-MsiInstallation.Tests/dotnet-MsiInstallation.Tests.csproj Removes obsolete CanRunTestAsTool property.
test/System.CommandLine.StaticCompletions.Tests/System.CommandLine.StaticCompletions.Tests.csproj Removes obsolete CanRunTestAsTool property.
test/SDDLTests/SDDLTests.csproj Removes obsolete CanRunTestAsTool property.
test/Microsoft.Win32.Msi.Tests/Microsoft.Win32.Msi.Tests.csproj Removes obsolete CanRunTestAsTool property.
test/Microsoft.Win32.Msi.Manual.Tests/Microsoft.Win32.Msi.Manual.Tests.csproj Removes obsolete CanRunTestAsTool property.
test/Microsoft.WebTools.AspireService.Tests/Microsoft.WebTools.AspireService.Tests.csproj Adds IsPackable (needs review vs removal of tool packing).
test/Microsoft.NET.TestFramework/SdkTestContext.cs Removes “run as tool” branching and simplifies directory resolution logic.
test/Microsoft.DotNet.PackageInstall.Tests/Microsoft.DotNet.PackageInstall.Tests.csproj Removes obsolete CanRunTestAsTool property.
test/EndToEnd.Tests/EndToEnd.Tests.csproj Removes obsolete CanRunTestAsTool property.
test/Directory.Build.targets Removes TestAsTool MSBuild target and tool-packing property group.
test/ArgumentForwarding.Tests/ArgumentForwarding.Tests.csproj Removes obsolete CanRunTestAsTool property.
eng/pipelines/templates/jobs/sdk-job-matrix.yml Removes “TestAsTools” job category from the matrix.
eng/pipelines/templates/jobs/sdk-build.yml Removes runTestsAsTool parameter and MSBuild property flow.
benchmarks/MicroBenchmark/MicroBenchmark.csproj Removes obsolete CanRunTestAsTool property.
OverrideTest.targets Deletes the target override used to route TestTestAsTool.
Directory.Build.targets Removes conditional import of OverrideTest.targets.

Comment on lines +207 to +209
testContext.TestAssetsDirectory =
(Directory.Exists(basePath) ? basePath : null)
?? Environment.GetEnvironmentVariable("DOTNET_SDK_TEST_ASSETS_DIRECTORY")
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

The new coalesce chain uses Environment.GetEnvironmentVariable("DOTNET_SDK_TEST_ASSETS_DIRECTORY") directly. If that variable is set but empty, TestAssetsDirectory becomes "" (or whitespace) and later path operations can fail in non-obvious ways. Consider using string.IsNullOrEmpty (or trimming) so empty values are treated the same as null and the fallback (FindFolderInTree) is used instead.

Suggested change
testContext.TestAssetsDirectory =
(Directory.Exists(basePath) ? basePath : null)
?? Environment.GetEnvironmentVariable("DOTNET_SDK_TEST_ASSETS_DIRECTORY")
string? testAssetsDirectoryEnvironment = Environment.GetEnvironmentVariable("DOTNET_SDK_TEST_ASSETS_DIRECTORY");
if (string.IsNullOrWhiteSpace(testAssetsDirectoryEnvironment))
{
testAssetsDirectoryEnvironment = null;
}
testContext.TestAssetsDirectory =
(Directory.Exists(basePath) ? basePath : null)
?? testAssetsDirectoryEnvironment

Copilot uses AI. Check for mistakes.
Comment on lines +228 to 232
testContext.TestExecutionDirectory =
commandLine.TestExecutionDirectory
?? Environment.GetEnvironmentVariable("DOTNET_SDK_TEST_EXECUTION_DIRECTORY")
?? Path.Combine(FindFolderInTree("artifacts", AppContext.BaseDirectory)!, "tmp", repoConfiguration, "testing");

Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

Similarly, TestExecutionDirectory now accepts DOTNET_SDK_TEST_EXECUTION_DIRECTORY as-is. If it is set to an empty string, Directory.CreateDirectory(TestExecutionDirectory) will throw (ArgumentException). Consider ignoring empty/whitespace values and falling back to the artifacts-based path.

Suggested change
testContext.TestExecutionDirectory =
commandLine.TestExecutionDirectory
?? Environment.GetEnvironmentVariable("DOTNET_SDK_TEST_EXECUTION_DIRECTORY")
?? Path.Combine(FindFolderInTree("artifacts", AppContext.BaseDirectory)!, "tmp", repoConfiguration, "testing");
string? testExecutionDirectory = commandLine.TestExecutionDirectory;
if (string.IsNullOrWhiteSpace(testExecutionDirectory))
{
string? envTestExecutionDirectory = Environment.GetEnvironmentVariable("DOTNET_SDK_TEST_EXECUTION_DIRECTORY");
if (!string.IsNullOrWhiteSpace(envTestExecutionDirectory))
{
testExecutionDirectory = envTestExecutionDirectory;
}
}
if (string.IsNullOrWhiteSpace(testExecutionDirectory))
{
testExecutionDirectory = Path.Combine(FindFolderInTree("artifacts", AppContext.BaseDirectory)!, "tmp", repoConfiguration, "testing");
}
testContext.TestExecutionDirectory = testExecutionDirectory;

Copilot uses AI. Check for mistakes.
<TargetFramework>$(SdkTargetFramework)</TargetFramework>
<RootNamespace>Microsoft.WebTools.AspireServer.UnitTests</RootNamespace>
<OutputType>Exe</OutputType>
<IsPackable>true</IsPackable>
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

This test project now explicitly sets true. With the PR removing the “tests as tools” packing flow, making a test project packable again seems unintended and can cause it to be included in repo-wide pack/signing steps. If there’s no longer a need to generate a NuGet package here, this should likely be removed or set to false to match other test projects in this repo.

Suggested change
<IsPackable>true</IsPackable>
<IsPackable>false</IsPackable>

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it's not clear why or if this is needed.

Copy link
Member

@MiYanni MiYanni left a comment

Choose a reason for hiding this comment

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

Thank you for doing this. One of those things on the list of "stuff after repo merge" I never got around to investigating. ❤️

testContext.TestExecutionDirectory =
commandLine.TestExecutionDirectory
?? Environment.GetEnvironmentVariable("DOTNET_SDK_TEST_EXECUTION_DIRECTORY")
?? Path.Combine(FindFolderInTree("artifacts", AppContext.BaseDirectory)!, "tmp", repoConfiguration, "testing");
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this could throw a NullReferenceException if FindFolderInTree returns null.

Copy link
Member Author

Choose a reason for hiding this comment

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

FindFolderInTree throws by default if the folder is not found - https://github.com/dotnet/sdk/blob/main/test/Microsoft.NET.TestFramework/SdkTestContext.cs#L405

The FindFolderInTree api could maybe be designed a little better but that is outside the scope of this PR.

<TargetFramework>$(SdkTargetFramework)</TargetFramework>
<RootNamespace>Microsoft.WebTools.AspireServer.UnitTests</RootNamespace>
<OutputType>Exe</OutputType>
<IsPackable>true</IsPackable>
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it's not clear why or if this is needed.

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.

3 participants