Don't build native host tests when building clr subset#125861
Open
elinor-fung wants to merge 2 commits intodotnet:mainfrom
Open
Don't build native host tests when building clr subset#125861elinor-fung wants to merge 2 commits intodotnet:mainfrom
elinor-fung wants to merge 2 commits intodotnet:mainfrom
Conversation
Building the clr subset includes host.native, which previously unconditionally built native test assets (mockcoreclr, mockhostfxr, mockhostpolicy, nativehost, etc.) via add_subdirectory(test) in the corehost CMakeLists.txt. These test assets are not needed for a normal dev build like './build.sh libs+clr -rc Release'. Add two CMake variables to control what gets built: - CLR_CMAKE_BUILD_HOST_PRODUCT: gates product-only targets (fxr, hostpolicy, apphost, dotnet, comhost) - CLR_CMAKE_BUILD_HOST_TESTS: gates the test subdirectory These are driven by MSBuild properties BuildNativeHostProduct and BuildNativeHostTests in corehost.proj, which default to true and false respectively. In eng/Subsets.props, the host.tests subset now invokes corehost.proj with BuildNativeHostTests=true and BuildNativeHostProduct=false, so only test assets and their required dependencies (hostcommon, hostmisc, nethost, ijwhost) are built. Fixes dotnet#73711 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the native host build so that building the clr subset no longer implicitly builds native host test assets, while still allowing host.tests to build the test assets without building full host “product” binaries.
Changes:
- Add MSBuild properties in
corehost.projto drive two new CMake variables controlling host product vs. host tests build. - Gate
src/native/corehostCMake subdirectories (fxr/hostpolicy/apphost/dotnet,test, andcomhost) behind those variables. - Update
eng/Subsets.propssohost.testsexplicitly buildscorehost.projwith tests enabled and product disabled.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/native/corehost/corehost.proj | Adds BuildNativeHostTests / BuildNativeHostProduct defaults and forwards them to CMake via -cmakeargs. |
| src/native/corehost/CMakeLists.txt | Conditionally includes product and test subdirectories (and ASAN install locations) based on the new CMake variables. |
| eng/Subsets.props | Updates host.tests subset to invoke corehost.proj with tests on and product off. |
Define default values so standalone CMake invocations (without MSBuild passing -D flags) produce a correct product build. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jkoritzinsky
approved these changes
Mar 20, 2026
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.
Building the
clrsubset includeshost.native, which previously unconditionally built native test assets (mockcoreclr, mockhostfxr, mockhostpolicy, nativehost, etc.) viaadd_subdirectory(test)in the corehost CMakeLists.txt. These test assets are not needed for a normal dev build like./build.sh libs+clr -rc Release. Since that is part of the baseline build agents are instructed to do, this also reduces the amount of work/time for all agents working in this repo.Changes
Add two CMake variables to control what gets built:
CLR_CMAKE_BUILD_HOST_PRODUCT: gates product-only targets (fxr, hostpolicy, apphost, dotnet, comhost)CLR_CMAKE_BUILD_HOST_TESTS: gates the test subdirectoryThese are driven by MSBuild properties
BuildNativeHostProductandBuildNativeHostTestsincorehost.proj, which default totrueandfalserespectively.In
eng/Subsets.props, thehost.testssubset now invokescorehost.projwithBuildNativeHostTests=trueandBuildNativeHostProduct=false, so only test assets and their required dependencies (hostcommon, hostmisc, nethost, ijwhost) are built.Subset behavior
host.native(used byclr)host.testshost(full)host.native)host.tests)Fixes #73711