Skip to content

Centralize eng/common build defaults in tools.ps1/tools.sh#17025

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-tools-ps1-defaults
Draft

Centralize eng/common build defaults in tools.ps1/tools.sh#17025
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-tools-ps1-defaults

Conversation

Copilot AI commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Makes eng/common/tools.ps1 and eng/common/tools.sh the single source of truth for build defaults (binaryLog, nodeReuse, configuration, verbosity, warnAsError, warnNotAsError, msbuildEngine, runtimeSourceFeed/Key, prepareMachine, restore). Previously these defaults were duplicated in the importing scripts (build, msbuild, sdk-task, darc-init, dotnet-install), and on the PowerShell side a declared [switch]/[bool]/[string] parameter is always defined, so it masked the CI/environment-aware defaults in tools.ps1 — e.g. a switch-based entry point invoked with -ci got binaryLog=$false instead of $true, and nodeReuse stayed $true on CI.

Approach

PowerShell: opt-in, declared-parameter-aware unbinding

An importer opts in by assigning its bound parameters before dot-sourcing:

$importerBoundParameters = $PSBoundParameters
. $PSScriptRoot\tools.ps1

tools.ps1 then drops only the managed variables that the importer declares as a parameter but did not pass, so the CI/environment-aware defaults take effect. Values passed explicitly, or set by assignment (e.g. sdk-task.ps1 computing $binaryLog/$warnAsError), are preserved because only declared-but-unpassed parameters are unbound. The block is skipped entirely for scripts that do not opt in, so external/out-of-repo consumers keep their current behavior.

Opted in: build.ps1, msbuild.ps1, sdk-task.ps1, dotnet-install.ps1, darc-init.ps1.

Bash

No masking exists (${var:-default}), so the duplicated default initializers were simply removed from build.sh, msbuild.sh, sdk-task.sh, darc-init.sh and left to tools.sh.

Notable changes

  • tools.ps1 / tools.sh — own all the defaults; folded the MSBUILD_NODEREUSE_ENABLED CI override into the nodeReuse/node_reuse default; tools.sh now defaults configuration to Release when source_build is true (only when not explicitly provided), otherwise Debug.
  • build.ps1 / build.sh / msbuild.ps1 / msbuild.sh — removed the duplicated defaults and the redundant post-import CI nodeReuse override blocks. Net behavior: nodeReuse now follows tools (no node reuse on CI unless MSBUILD_NODEREUSE_ENABLED=1), while an explicitly passed -nodeReuse/--nodereuse is respected.
  • sdk-task.ps1 / sdk-task.shrestore now defaults to true and is folded into a single MSBuild /restore invocation (the separate Restore pass is gone); replaced the -restore flag with -noRestore/--no-restore; added prepareMachine/--preparemachine to the bash script for parity; inlined the now single-use Build function (Execute is the only target); fixed the bash --noWarnAsError case label (was never matching the lowercased input).
  • Pipeline call sites (publish-build-assets.yml, post-build.yml, publishing/v3/publish.yml, onboarding doc) — dropped the now-redundant -restore argument from sdk-task.ps1 invocations.

Validation

All edited PowerShell files parse via the PS parser; all edited shell files pass bash -n. The opt-in unbinding mechanism was verified on both PowerShell 5.1 and Core: explicitly passed values and assignment-set values are preserved, declared-but-unpassed managed parameters fall back to the tools defaults.

To double check:

Copilot AI self-assigned this Jun 18, 2026
Copilot AI review requested due to automatic review settings June 18, 2026 16:10
Copilot AI removed the request for review from Copilot June 18, 2026 16:10
Copilot AI requested review from Copilot and removed request for Copilot June 18, 2026 16:18
Copilot AI changed the title [WIP] Fix defaults for bool switch conditions in tools.ps1 Fix eng/common/tools.ps1 switch-parameter defaults Jun 18, 2026
Copilot AI requested a review from ViktorHofer June 18, 2026 16:19
Make tools.ps1/tools.sh the single source of truth for build defaults
(binaryLog, nodeReuse, configuration, verbosity, warnAsError, etc.) and
remove the duplicated/masking defaults from build, msbuild, sdk-task,
darc-init and dotnet-install. PowerShell importers opt in via
$importerBoundParameters so tools.ps1 unbinds declared-but-unpassed
parameters while preserving explicitly passed and assignment-set values.

Also: default source-build configuration to Release in tools.sh; fold
sdk-task restore into a single MSBuild /restore invocation with a
-noRestore/--no-restore switch; add prepareMachine to sdk-task.sh; and
fix sdk-task.sh's --noWarnAsError case label.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 18, 2026 19:44
@ViktorHofer ViktorHofer changed the title Fix eng/common/tools.ps1 switch-parameter defaults Centralize eng/common build defaults in tools.ps1/tools.sh Jun 18, 2026

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 updates Arcade’s shared eng/common tooling to ensure CI/environment-aware defaults (notably binaryLog and nodeReuse) are applied correctly when importing scripts declare [switch]/[bool] parameters, and it aligns several entrypoints/templates to rely on those centralized defaults.

Changes:

  • Add an opt-in mechanism in eng/common/tools.ps1 to “unbind” declared-but-unpassed parameters so tools-owned defaults apply.
  • Centralize source-build configuration defaulting and CI node-reuse behavior in eng/common/tools.sh / tools.ps1, removing redundant overrides from wrappers.
  • Update sdk-task scripts and pipeline templates/docs to reflect new default restore behavior (with -noRestore / --no-restore).
Show a summary per file
File Description
eng/publishing/v3/publish.yml Drops explicit -restore for sdk-task.ps1 invocation (restore now defaults on).
eng/common/tools.sh Moves source-build configuration defaulting and CI node-reuse gating into shared defaults.
eng/common/tools.ps1 Adds opt-in parameter “unbinding” so tools-owned defaults aren’t masked by declared params; updates node-reuse default to honor MSBUILD_NODEREUSE_ENABLED.
eng/common/sdk-task.sh Switches restore control to --no-restore and simplifies execution to a single MSBuild call with optional /restore.
eng/common/sdk-task.ps1 Switches restore control to -noRestore and simplifies execution to a single MSBuild call with optional /restore; opts in to tools-managed defaults.
eng/common/msbuild.sh Relies on tools.sh for defaults; removes redundant CI node-reuse override.
eng/common/msbuild.ps1 Opts in to tools-managed defaults; removes redundant CI node-reuse override.
eng/common/dotnet-install.ps1 Opts in to tools-managed defaults for verbosity/runtime feed parameters.
eng/common/darc-init.sh Relies on tools.sh for verbosity default.
eng/common/darc-init.ps1 Opts in to tools-managed defaults for verbosity.
eng/common/core-templates/post-build/post-build.yml Drops explicit -restore for sdk-task.ps1 invocation.
eng/common/core-templates/job/publish-build-assets.yml Drops explicit -restore for sdk-task.ps1 invocation.
eng/common/build.sh Removes duplicated CI/config defaulting logic in favor of tools.sh.
eng/common/build.ps1 Opts in to tools-managed defaults and removes duplicated CI overrides for binlog/node reuse.
Documentation/DependencyFlowOnboardingWithoutArcade.md Updates example to remove explicit -restore/-msbuildEngine lines.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 15/15 changed files
  • Comments generated: 4

Comment thread eng/common/tools.ps1
Comment on lines +15 to +22
if (Test-Path variable:importerBoundParameters) {
$importerDeclaredParameters = (Get-PSCallStack)[1].InvocationInfo.MyCommand.Parameters.Keys
foreach ($toolsManagedDefault in @('binaryLog', 'nodeReuse', 'warnAsError', 'warnNotAsError', 'verbosity', 'configuration', 'msbuildEngine', 'runtimeSourceFeed', 'runtimeSourceFeedKey')) {
if (($importerDeclaredParameters -contains $toolsManagedDefault) -and -not $importerBoundParameters.ContainsKey($toolsManagedDefault)) {
Remove-Variable -Name $toolsManagedDefault -ErrorAction SilentlyContinue
}
}
}
Comment thread eng/common/sdk-task.ps1
Comment on lines 2 to 10
Param(
[string] $configuration = 'Debug',
[string] $configuration,
[string] $task,
[string] $verbosity = 'minimal',
[string] $msbuildEngine = $null,
[switch] $restore,
[string] $verbosity,
[string] $msbuildEngine,
[switch] $noRestore,
[switch] $prepareMachine,
[switch][Alias('nobl')]$excludeCIBinaryLog,
[switch]$noWarnAsError,
Comment thread eng/common/sdk-task.sh
Comment on lines 37 to 46
case $lowerI in
--task)
task=$2
shift 2
;;
--restore)
restore=true
--no-restore)
restore=false
shift 1
;;
--verbosity)
Comment on lines 82 to 84
arguments: -task PublishBuildAssets
-restore
-msbuildEngine dotnet
/p:ManifestsPath='$(Build.StagingDirectory)/Download/AssetManifests'
/p:MaestroApiEndpoint=https://maestro.dot.net"
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.

3 participants