Skip to content

Compile the MTP client out of source-only builds - #16385

Merged
Jakub Jareš (nohwnd) merged 1 commit into
microsoft:mainfrom
nohwnd:nohwnd-cut-mtp-client-from-source-build
Aug 19, 2026
Merged

Jakub Jareš (nohwnd) merged 1 commit into
microsoft:mainfrom
nohwnd:nohwnd-cut-mtp-client-from-source-build

Conversation

@nohwnd

Copy link
Copy Markdown
Member

#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 DotNetBuildSourceOnly and compile out the code that needs it:

  • Client/MTP in CrossPlatEngine
  • MtpTestRuntimeProvider in TestHostProvider, and its entry in TestExtensionTypes
  • the MTP unit tests

Running 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 Release is green with no new warnings.
  • build.cmd -c Release /p:DotNetBuildSourceOnly=true is green, and Microsoft.Testing.Platform.ServerMode.Client.Sources is gone from every project.assets.json.
  • CrossPlatEngine unit tests pass, 73 of them cover the MTP client.

🤖

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.

🤖
Copilot AI lite review requested due to automatic review settings August 18, 2026 15:11

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 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.Sources on DotNetBuildSourceOnly != true and compile out Client/MTP for source-only builds.
  • Compile out MtpTestRuntimeProvider for source-only builds and remove it from TestExtensionTypes registration under DOTNET_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.

@nohwnd
Jakub Jareš (nohwnd) merged commit 7e128f4 into microsoft:main Aug 19, 2026
20 checks passed
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

🤖
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants