Compile the MTP client out of source-only builds - #16385
Merged
Jakub Jareš (nohwnd) merged 1 commit intoAug 19, 2026
Merged
Jakub Jareš (nohwnd) merged 1 commit into
Jakub Jareš (nohwnd) merged 1 commit into
Conversation
microsoft/testfx is not a VMR repo, so Microsoft.Testing.Platform.ServerMode.Client.Sources is not produced in a source-only build and gets restored from an external feed. The VMR sees that as a prebuilt and fails the build, and since .NET 10 there is no per-repo prebuilt baseline to exclude it with. Condition the PackageReference on DotNetBuildSourceOnly and compile out the code that needs it: Client/MTP in CrossPlatEngine, MtpTestRuntimeProvider, and the MTP tests. Running MTP applications under vstest is opt-in and off by default, so this only drops that feature from source-only builds. Normal builds are not affected. Temporary until the package is available to source-build, see dotnet/dotnet#8349. 🤖
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the VSTest build to avoid restoring the Microsoft.Testing.Platform.ServerMode.Client.Sources source-only package during source-only builds (VMR/source-build scenario), by conditioning the PackageReference on DotNetBuildSourceOnly and compiling out the MTP-dependent code paths. This keeps normal builds unchanged while preventing source-build failures caused by restoring a “prebuilt” from external feeds.
Changes:
- Condition
Microsoft.Testing.Platform.ServerMode.Client.SourcesonDotNetBuildSourceOnly != trueand compile outClient/MTPfor source-only builds. - Compile out
MtpTestRuntimeProviderfor source-only builds and remove it fromTestExtensionTypesregistration underDOTNET_BUILD_FROM_SOURCE. - Exclude MTP unit tests from source-only builds.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Microsoft.TestPlatform.CrossPlatEngine.UnitTests.csproj | Removes MTP unit test sources from compilation in source-only builds. |
| src/Microsoft.TestPlatform.TestHostProvider/Properties/AssemblyInfo.cs | Excludes MtpTestRuntimeProvider from TestExtensionTypes registration when building from source. |
| src/Microsoft.TestPlatform.TestHostProvider/Microsoft.TestPlatform.TestHostProvider.csproj | Removes Hosting/MtpTestRuntimeProvider.cs from compilation in source-only builds. |
| src/Microsoft.TestPlatform.CrossPlatEngine/Microsoft.TestPlatform.CrossPlatEngine.csproj | Conditions the MTP source-package reference and compiles out Client/MTP for source-only builds. |
| src/Microsoft.TestPlatform.CrossPlatEngine/Client/IProxyManagerFactory.cs | Updates XML doc text to avoid referencing MTP types via cref when the MTP client is compiled out. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Alexander Köplinger (akoeplinger)
approved these changes
Aug 18, 2026
Azat Mukhametshin (azat-msft)
approved these changes
Aug 19, 2026
Jakub Jareš (nohwnd)
added a commit
to dotnet/dotnet
that referenced
this pull request
Aug 19, 2026
Microsoft.Testing.Platform.ServerMode.Client.Sources is a source-only package from microsoft/testfx, and testfx is not a VMR repo, so the package cannot be produced in a source-only build and the prebuilt detector fails the build on it. Since .NET 10 there is no per-repo baseline left to add an exclusion to, so the reference has to go instead. Condition the package reference and the MTP sources on DotNetBuildSourceOnly. Normal builds are not affected. Source-only builds lose running MTP applications under vstest, which is opt-in and off by default. Two spots needed more than an ItemGroup condition. MtpTestRuntimeProvider is registered in TestExtensionTypes, so that registration is now behind DOTNET_BUILD_FROM_SOURCE. The IProxyManagerFactory doc comment crefs MtpProxyManagerFactory, and with GenerateDocumentationFile and warnings as errors that turns into CS1574 once the type is compiled out, so it is a plain <c> tag now. This is temporary. The real fix is either shipping the package through dotnet/source-build-assets as a text-only package, or vendoring the source with drift tracking, the way dotnet/sdk#55130 (Vendor dotnet test shared source instead of consuming the Internal.DotnetTest package) did for the sibling package. The same change is in microsoft/vstest#16385 (Compile the MTP client out of source-only builds) so it survives the next codeflow: microsoft/vstest#16385 🤖
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#16300 added a PackageReference to
Microsoft.Testing.Platform.ServerMode.Client.Sources. microsoft/testfx is not a VMR repo, so that package is not produced in a source-only build and gets restored from an external feed. The VMR sees it as a prebuilt and fails, see dotnet/dotnet#8349. Since .NET 10 there is no per-repo prebuilt baseline, so there is nothing to exclude it with either.Condition the PackageReference on
DotNetBuildSourceOnlyand compile out the code that needs it:Client/MTPin CrossPlatEngineMtpTestRuntimeProviderin TestHostProvider, and its entry inTestExtensionTypesRunning MTP applications under vstest is opt-in (
VSTEST_DISABLE_MTP_TESTHOST=0) and off by default, so this only drops that feature from source-only builds. Normal builds are not affected.Temporary. The real fix is either adding the package to dotnet/source-build-assets as a text-only package, or vendoring the source with drift tracking the way dotnet/sdk#55130 did for
Microsoft.Testing.Platform.Internal.DotnetTest. When either of those lands this can be reverted.Verified locally:
build.cmd -c Releaseis green with no new warnings.build.cmd -c Release /p:DotNetBuildSourceOnly=trueis green, andMicrosoft.Testing.Platform.ServerMode.Client.Sourcesis gone from everyproject.assets.json.🤖