-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Remove RunTestsAsTool Concept #53010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
CanRunTestAsToolusage from test/benchmark projects and deletes theTestAsToolMSBuild target +OverrideTest.targets. - Drops the AzDO “TestAsTools” job category and removes
runTestsAsToolpipeline plumbing. - Simplifies
SdkTestContext.Initializepath 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 Test → TestAsTool. |
| Directory.Build.targets | Removes conditional import of OverrideTest.targets. |
| testContext.TestAssetsDirectory = | ||
| (Directory.Exists(basePath) ? basePath : null) | ||
| ?? Environment.GetEnvironmentVariable("DOTNET_SDK_TEST_ASSETS_DIRECTORY") |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
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.
| 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 |
| testContext.TestExecutionDirectory = | ||
| commandLine.TestExecutionDirectory | ||
| ?? Environment.GetEnvironmentVariable("DOTNET_SDK_TEST_EXECUTION_DIRECTORY") | ||
| ?? Path.Combine(FindFolderInTree("artifacts", AppContext.BaseDirectory)!, "tmp", repoConfiguration, "testing"); | ||
|
|
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
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.
| 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; |
| <TargetFramework>$(SdkTargetFramework)</TargetFramework> | ||
| <RootNamespace>Microsoft.WebTools.AspireServer.UnitTests</RootNamespace> | ||
| <OutputType>Exe</OutputType> | ||
| <IsPackable>true</IsPackable> |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
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.
| <IsPackable>true</IsPackable> | |
| <IsPackable>false</IsPackable> |
There was a problem hiding this comment.
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.
MiYanni
left a comment
There was a problem hiding this 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"); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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.
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