Repository navigation
Support injecting the build tool via environment variables - #17094
Merged
ViktorHofer merged 1 commit intoJul 10, 2026
Merged
Conversation
Add a _BuildToolPath / _BuildToolCommand environment-variable hook to InitializeBuildTool in tools.ps1 and tools.sh. When _BuildToolPath is set, InitializeBuildTool returns that path/command instead of resolving the in-proc $global:_BuildTool / _InitializeBuildTool variable. This lets orchestration scripts (e.g. a two-stage bootstrap build) run build.ps1/build.sh out-of-process with a clean scope and still point MSBuild at a custom build tool, without dot-sourcing tools.ps1/tools.sh to set the internal variable. Co-authored-by: Copilot <[email protected]> Copilot-Session: 0ba1f12e-c9d7-4f5e-b31c-911fc21be955
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an environment-variable hook to InitializeBuildTool so external orchestration scripts can invoke build.sh / build.ps1 out-of-process while still directing MSBuild to use a caller-specified build tool path + command.
Changes:
- Add
_BuildToolPath/_BuildToolCommandenvironment-variable support toInitializeBuildToolintools.sh. - Add
_BuildToolPath/_BuildToolCommandenvironment-variable support toInitializeBuildToolintools.ps1.
Show a summary per file
| File | Description |
|---|---|
| eng/common/tools.sh | Adds env-var injection path for the build tool initialization used by MSBuild. |
| eng/common/tools.ps1 | Adds env-var injection path for the build tool initialization used by MSBuild. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 2
akoeplinger
approved these changes
Jul 10, 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.
Summary
Adds a
_BuildToolPath/_BuildToolCommandenvironment-variable hook toInitializeBuildToolin botheng/common/tools.ps1andeng/common/tools.sh.When
_BuildToolPathis set,InitializeBuildToolreturns that path/command directly instead of resolving the in-proc$global:_BuildTool(PowerShell) /_InitializeBuildTool(bash) variable. OnlyPathandCommandare consumed by theMSBuildfunction, so those are all that is injected.Motivation
Orchestration scripts such as a two-stage bootstrapped build currently have to dot-source
tools.ps1/tools.shin order to set the internal_BuildToolvariable before invokingbuild.ps1/build.sh. Dot-sourcing forces in-proc execution and leaks the toolset's dynamically-scoped variables into the caller (and into any child script the caller runs).This hook lets those scripts invoke
build.ps1/build.shout-of-process with a clean scope while still pointing MSBuild at a custom (e.g. freshly-bootstrapped) build tool, purely via environment variables.Notes
_BuildToolPathis unset — the existing resolution path is unchanged.dotnet/msbuildis the initial consumer (itscibuild_bootstrapped_msbuildscripts).