Skip to content

Refactor bootstrapped build infrastructure - #14361

Merged
ViktorHofer merged 20 commits into
mainfrom
InfraRefactoring
Jul 16, 2026
Merged

ViktorHofer merged 20 commits into
mainfrom
InfraRefactoring

Conversation

@ViktorHofer

Copy link
Copy Markdown
Member

Summary

Refactors the bootstrapped build infrastructure, consolidating the multi-stage build logic into the eng/build.ps1 / eng/build.sh wrapper scripts and removing now-redundant helper scripts.

Highlights

  • Rewrote eng/build.ps1 around an explicit -stage2 switch: single-stage by default, with the two-stage bootstrap flow running only when -stage2 is requested (or -stage2Arguments are supplied).
  • Added eng/build.sh as the aligned bash counterpart, mirroring the PowerShell logic (staging behavior, --test opt-in, stage2Arguments handling, bootstrap tool/env-var handoff). There is only one MSBuild engine (dotnet) on non-Windows, so no engine selection is performed there.
  • Removed the standalone eng/cibuild_bootstrapped_msbuild.{cmd,ps1,sh} helpers and other obsolete infra files, folding their responsibilities into the wrapper scripts and pipeline YAML.
  • Updated Azure Pipelines definitions and build.cmd / build.sh entry points accordingly.

Notes

  • eng/common/** (Arcade-owned) is intentionally left untouched; only MSBuild-specific wrapper scripts are modified.

Draft for CI validation and review.

@ViktorHofer
ViktorHofer marked this pull request as ready for review July 15, 2026 10:43
@ViktorHofer
ViktorHofer requested a review from a team as a code owner July 15, 2026 10:43
Copilot AI review requested due to automatic review settings July 15, 2026 10:43

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

Refactors MSBuild’s bootstrapped (multi-stage) build infrastructure by moving stage orchestration into eng/build.ps1 and a new eng/build.sh, removing older helper scripts, and updating Azure Pipelines and entrypoints (build.cmd / build.sh) to use the new flow.

Changes:

  • Introduces aligned stage1/stage2 wrapper scripts (eng/build.ps1 and new eng/build.sh) and removes the legacy eng/cibuild_bootstrapped_msbuild.* helpers.
  • Updates pipeline YAML and repo entrypoints to route CI through the new wrappers.
  • Replaces the old “produces no output” import mechanism in some projects with ExcludeFromBuild, and moves the EngineServices version-bump enforcement into Microsoft.Build.Framework.csproj.
Show a summary per file
File Description
src/UnitTests.Shared/RunnerUtilities.cs Removes outdated comment reference to deleted bootstrap scripts.
src/Tasks/Copy.cs Trims outdated local-build instructions in comments.
src/Package/MSBuild.VSSetup/MSBuild.VSSetup.csproj Switches skip mechanism from ShouldSkipProject/import to ExcludeFromBuild.
src/Package/MSBuild.VSSetup.Arm64/MSBuild.VSSetup.Arm64.csproj Same skip-mechanism refactor for Arm64 VSSetup.
src/Package/DevDivPackage/DevDivPackage.csproj Adjusts build exclusion behavior for non-Full runtime builds.
src/MSBuildTaskHost/MSBuildTaskHost.csproj Changes how net35 TaskHost is excluded on non-Full runtime builds.
src/Framework/Microsoft.Build.Framework.csproj Moves TLB packing target and adds CI PR-time EngineServices version-bump check.
src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj Tightens MSBuildTaskHost reference condition to Full runtime builds.
eng/ProducesNoOutput.Settings.props Deleted (previously used to no-op excluded projects).
eng/ProducesNoOutput.Imports.props Deleted (previously used to no-op excluded projects).
eng/generate-optprof-run-settings.ps1 Deleted helper script.
eng/configure-toolset.sh Deleted helper script.
eng/configure-toolset.ps1 Deleted helper script.
eng/CIBuild.cmd Deleted legacy CI entrypoint.
eng/cibuild_bootstrapped_msbuild.sh Deleted legacy two-stage bash helper.
eng/cibuild_bootstrapped_msbuild.ps1 Deleted legacy two-stage PowerShell helper.
eng/cibuild_bootstrapped_msbuild.cmd Deleted legacy cmd shim for the PowerShell helper.
eng/build.sh New bash wrapper that implements stage1/stage2 orchestration.
eng/build.ps1 Refactored PowerShell wrapper implementing stage1/stage2 orchestration.
documentation/wiki/Building-Testing-and-Debugging-on-Full-Framework-MSBuild.md Updates instructions for mimicking CI locally.
build.sh Updates repo-root entrypoint to call eng/build.sh.
build.cmd Updates repo-root entrypoint to call eng/build.ps1.
azure-pipelines/quarantine.yml Updates quarantined test runs to use new build entrypoints.
azure-pipelines/cts-steps/collect-steps.yml Updates CTS collect step to use repo entrypoints.
azure-pipelines/cts-steps/apply-steps.yml Updates CTS apply step to use repo entrypoints.
azure-pipelines/.vsts-dotnet-exp-perf.yml Removes stale comments.
azure-pipelines/.vsts-dotnet-build-jobs.yml Updates official build step invocation and related variables.
.vsts-dotnet.yml Adjusts variables for optimization-data handling.
.vsts-dotnet-ci.yml Updates CI build steps to use new wrappers/args.
.github/workflows/copilot-setup-steps.yml Updates restore step to use repo-root build.sh.

Copilot's findings

  • Files reviewed: 30/30 changed files
  • Comments generated: 9

Comment thread build.cmd
Comment thread eng/build.ps1
Comment thread eng/build.ps1 Outdated
Comment thread build.sh Outdated
Comment thread src/Framework/Microsoft.Build.Framework.csproj
Comment thread src/MSBuildTaskHost/MSBuildTaskHost.csproj
Comment thread src/Package/MSBuild.VSSetup/MSBuild.VSSetup.csproj
Comment thread src/Package/DevDivPackage/DevDivPackage.csproj
Comment thread azure-pipelines/cts-steps/collect-steps.yml Outdated
ViktorHofer and others added 6 commits July 15, 2026 12:57
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Emit no context lines in the EngineServices diff so the 'int Version ='
check only matches genuinely changed lines, not unchanged context.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f1a70d70-f0e7-4cc9-b2e5-527e980bcb78

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.

Copilot's findings

  • Files reviewed: 30/30 changed files
  • Comments generated: 1

Comment thread azure-pipelines/quarantine.yml
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: cda0bfa1-ae78-403f-8a53-cb4ec762ed0d
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: cda0bfa1-ae78-403f-8a53-cb4ec762ed0d
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: cda0bfa1-ae78-403f-8a53-cb4ec762ed0d
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: cda0bfa1-ae78-403f-8a53-cb4ec762ed0d

@jankratochvilcz jankratochvilcz 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.

Image

@rainersigwald

Copy link
Copy Markdown
Member
  • eng/common/** (Arcade-owned) is intentionally left untouched; only MSBuild-specific wrapper scripts are modified.

This isn't true but should be ok because of dotnet/arcade#17122

Comment thread build.cmd
Comment thread src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj
@ViktorHofer
ViktorHofer enabled auto-merge (squash) July 15, 2026 21:08
@ViktorHofer
ViktorHofer merged commit 9b7c97b into main Jul 16, 2026
10 checks passed
@ViktorHofer
ViktorHofer deleted the InfraRefactoring branch July 16, 2026 07:05
ViktorHofer pushed a commit that referenced this pull request Jul 28, 2026
I use a particular set of flags to build .NET VMR, which flows something
like this to the msbuild build scripts:

    $ ./build.sh /p:OfficialBuilder="Red Hat Inc."

This regressed recently (probably
#14361). This change fixes the
issue.

For arrays which can be empty, use the ${var[@]+"${var[@]}"} syntax, as
discussed in dotnet/dotnet#797, to avoid issues
on macOS.

Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
AR-May added a commit that referenced this pull request Aug 3, 2026
…14591)

PR #14361 changed the top-level build scripts to invoke the
repository-specific  `eng/build.ps1`  and  `eng/build.sh`  wrappers
instead of calling the Arcade build scripts directly.

Before that refactoring,  `-c`  and  `-t` were supported by
 `eng/common/build.ps1`  and  `eng/common/build.sh` . The new wrappers
retained the configuration  and  test  parameters, but did not retain
their short aliases.

On Windows, this caused  `build.cmd -c Release`  to fail because
PowerShell interpreted  `-c`  as ambiguous between  `-configuration` 
and  `-ci`.
Comment thread eng/build.sh
@@ -0,0 +1,135 @@
#! /bin/bash

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't portable. It's causing problems for me on NixOS. It should probably use the same shebang as the other scripts and assume bash is in $PATH.

Comment thread eng/build.sh
echo "Stage 1 build: /bin/bash \"$build_script\" $build_args"
fi

/bin/bash "$build_script" $build_args

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the other references to /bin/bash are also a problem.

ViktorHofer added a commit that referenced this pull request Aug 14, 2026
Follow-up to #14361 addressing @corngood's review feedback:
`eng/build.sh` isn't portable and breaks on NixOS.

- Shebang `#! /bin/bash` -> `#!/usr/bin/env bash`, matching every other
script in this repo (including `build.sh` and `eng/common/*.sh`).
- The hardcoded `/bin/bash` invocations of the stage 1 / stage 2 builds
now use `bash` from `\`. The echoed command lines were updated to match.

No behavioral change on distributions where bash lives at `/bin/bash`.

Copilot-Session: fcd4cd36-f7ca-48cf-9c4d-7f9601ef3db2
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.

6 participants