Skip to content

Default restore to true in sdk-task scripts - #17116

Merged
ViktorHofer merged 7 commits into
dotnet:mainfrom
ViktorHofer:viktorhofer/sdk-task-default-restore
Jul 14, 2026
Merged

ViktorHofer merged 7 commits into
dotnet:mainfrom
ViktorHofer:viktorhofer/sdk-task-default-restore

Conversation

@ViktorHofer

@ViktorHofer ViktorHofer commented Jul 14, 2026 •

Copy link
Copy Markdown
Member

Summary

sdk-task.ps1/sdk-task.sh default restore to false, diverging from tools.ps1's default of true (the .ps1 shadows the tools.ps1 default via its own [switch] $restore, which is always false unless passed).

This regressed in ea5fa16, which flipped the default from restoring-by-default to not restoring. That same commit reworked the SDK tasks to use PackageReference items, which means the tasks now need a restore in certain cases - so defaulting restore to false leaves those consumers broken.

This changes both scripts to default restore to true and adds a -norestore/--norestore opt-out.

Behavior

  • restore now defaults to true in both scripts.
  • New -norestore / --norestore flag skips the restore step.
  • -restore / --restore is retained as a legacy no-op so existing consumers that pass it don't break.

sdk-task.ps1/.sh previously defaulted restore to false, diverging from tools.ps1's default of true (which the .ps1 shadowed via its own [switch]). Default restore to true in both scripts and add a -norestore/--norestore opt-out. The -restore/--restore flag is retained as a legacy no-op so existing consumers that pass it don't break.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 9e366d06-83fa-487b-898d-dec74a8bea17
JanProvaznik
JanProvaznik previously approved these changes Jul 14, 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 the Arcade SDK task helper scripts to restore dependencies by default again (matching tools.ps1 behavior), and introduces an explicit opt-out flag so SDK tasks that now rely on PackageReference won’t break when consumers forget to restore.

Changes:

  • Default restore behavior to on in sdk-task.ps1 and sdk-task.sh.
  • Add -norestore / --norestore to explicitly skip restore.
  • Keep -restore / --restore as a backward-compatible legacy flag.
Show a summary per file
File Description
eng/common/sdk-task.sh Defaults restore to true, updates help text, and adds --norestore parsing.
eng/common/sdk-task.ps1 Defaults restore to true, adds -norestore, and makes restore execution depend on -norestore.

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: 1

Comment thread eng/common/sdk-task.sh Resolved
ViktorHofer added a commit to dotnet/msbuild that referenced this pull request Jul 14, 2026
> **Upstreamed:** This change is already submitted upstream to Arcade in
dotnet/arcade#17116. Since `eng/common` is mirrored from
[dotnet/arcade](https://github.com/dotnet/arcade), this PR applies the
same fix directly to msbuild so we don't have to wait for the Arcade
flow.

## Summary
`sdk-task.ps1`/`sdk-task.sh` defaulted `restore` to **false**, diverging
from `tools.ps1`'s default of `true` (the `.ps1` shadowed the
`tools.ps1` default via its own `[switch] $restore`, which is always
`false` unless passed).

This regressed upstream in
[dotnet/arcade@ea5fa16](dotnet/arcade@ea5fa16),
which flipped the default from restoring-by-default to not restoring.
That same commit reworked the SDK tasks to use `PackageReference` items,
which means the tasks now need a restore in certain cases - so
defaulting `restore` to false leaves those consumers broken.

This changes both scripts to default restore to **true** and adds a
`-norestore`/`--norestore` opt-out.

## Behavior
- `restore` now defaults to **true** in both scripts.
- New `-norestore` / `--norestore` flag skips the restore step.
- `-restore` / `--restore` is retained as a **legacy no-op** so existing
consumers that pass it don't break.
Copilot AI review requested due to automatic review settings July 14, 2026 12:47

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: 2/2 changed files
  • Comments generated: 2

Comment thread eng/common/sdk-task.ps1 Resolved
Comment thread eng/common/sdk-task.sh Resolved
sdk-task dot-sources tools.ps1/tools.sh, which imports configure-toolset.ps1/sh unless disableConfigureToolsetImport is set. A repo's configure-toolset can call exit and terminate sdk-task before the task runs. sdk-task runs a standalone Arcade SDK task and doesn't need repo-specific toolset setup, so skip the import (consistent with SetupNugetSources).

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 9e366d06-83fa-487b-898d-dec74a8bea17
Copilot AI review requested due to automatic review settings July 14, 2026 13:14

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: 2/2 changed files
  • Comments generated: 4

Comment thread eng/common/sdk-task.sh Resolved
Comment thread eng/common/sdk-task.sh Resolved
Comment thread eng/common/sdk-task.ps1 Resolved
Comment thread eng/common/sdk-task.ps1 Resolved
The arg loop lowercases each option (lowerI=... | tr [:upper:] [:lower:]) before matching, so the case pattern must be lowercase. --noWarnAsError never matched and was forwarded to MSBuild as a property instead of toggling warn-as-error. Lowercase the pattern to --nowarnaserror.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 9e366d06-83fa-487b-898d-dec74a8bea17
Copilot AI review requested due to automatic review settings July 14, 2026 13:17
The previous 'restore is always on' wording implied --norestore/-norestore was ineffective. Reword help text and inline comments to state restore runs by default and can be skipped with --norestore/-norestore.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 9e366d06-83fa-487b-898d-dec74a8bea17

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: 2/2 changed files
  • Comments generated: 1

Comment thread eng/common/sdk-task.ps1 Resolved
Copilot AI review requested due to automatic review settings July 14, 2026 13:21

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: 2/2 changed files
  • Comments generated: 0 new

tools.ps1 reads \ at import time to decide whether toolset/SDK acquisition installs. Previously -norestore only skipped the explicit Build 'Restore' call while \ stayed true, so toolset initialization still restored. Set \=\False when -norestore is passed before dot-sourcing tools.ps1, mirroring what sdk-task.sh already does (it sets restore=false before sourcing tools.sh).

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 9e366d06-83fa-487b-898d-dec74a8bea17
Copilot AI review requested due to automatic review settings July 14, 2026 13:24

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: 2/2 changed files
  • Comments generated: 2

Comment thread eng/common/sdk-task.sh Resolved
Comment thread eng/common/sdk-task.sh Resolved
tools.sh's MSBuild helper reads warn_as_error (snake_case), but sdk-task.sh set warnAsError (camelCase, the PowerShell variable name), which was never consumed - so --noWarnAsError had no effect on the build. Rename to warn_as_error so the flag actually disables warnings-as-errors. (sdk-task.ps1 is correct: tools.ps1 consumes \.)

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 9e366d06-83fa-487b-898d-dec74a8bea17
Copilot AI review requested due to automatic review settings July 14, 2026 13:32

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: 2/2 changed files
  • Comments generated: 0 new

@ViktorHofer
ViktorHofer enabled auto-merge (squash) July 14, 2026 13:42
@ViktorHofer
ViktorHofer merged commit 678dcfb into dotnet:main Jul 14, 2026
9 of 10 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 15, 2026
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