Skip to content

Show restore diagnostics when aspire update fails - #22355

Merged
James Newton-King (JamesNK) merged 1 commit into
mainfrom
jamesnk/fix-update-restore-diagnostics
Nov 17, 2026
Merged

James Newton-King (JamesNK) merged 1 commit into
mainfrom
jamesnk/fix-update-restore-diagnostics

Conversation

@JamesNK

@JamesNK James Newton-King (JamesNK) commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Description

When the post-update package restore fails, aspire update currently reports only a generic failure. This hides actionable NuGet/MSBuild errors such as access denied to a locked task assembly.

Capture restore stdout and stderr in the existing CLI file log and display the captured output after the restore status finishes when restore fails. Successful restores remain quiet, and update rollback and exit code 13 are unchanged. Reuse the existing OutputCollector and update the CLI documentation.

This fixes restore diagnostics only; it does not change DLL locking or stop shared MSBuild servers. No new dependencies.

Fixes #22352

User-facing usage

The existing command requires no new options:

aspire update --channel staging

Failure output before and after

Example for the locked task-assembly failure reported in #22352 (project/log paths abbreviated; progress and status icons omitted):

Before

Failed to restore packages for project <AppHost.csproj> after update.
See logs at <cli.log>

After

error : Access to the path 'Aspire.Hosting.Tasks.dll' is denied.
Failed to restore packages for project <AppHost.csproj> after update.
See logs at <cli.log>

The underlying restore stdout and stderr are now also captured in the CLI log. The generic failure summary, rollback, and exit code 13 are unchanged.

Command help is unchanged; verified from the locally built CLI:

Usage:
  aspire update [options]

Validation

Windows, .NET SDK 11.0.100. Revalidated on this branch based directly on current main.

$env:MSBUILDTERMINALLOGGER='false'; dotnet test --project tests\Aspire.Cli.Tests\Aspire.Cli.Tests.csproj --no-restore --no-launch-profile -- --filter-class '*.ProjectUpdater*' --filter-class '*.UpdateCommandTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'

Passed: 401 succeeded, 2 platform-specific skips, 0 failures. The four new regression cases cover project and file-based AppHosts, stdout/stderr logging, failure-only display, and rollback. All four failed before the fix because the output was missing.

dotnet exec artifacts\bin\Aspire.Cli\Debug\net11.0\aspire.dll update --help

Passed: command help rendered successfully.

git diff --check

Passed before committing.

The investigation also reproduced task DLL retention using a disposable copy and an isolated MSBuild server. Deletion failed after the build completed, succeeded after stopping only that test server, and succeeded immediately in a server-disabled control. The original worker's caller remains unproven; no shared build servers were stopped.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Capture restore stdout and stderr in the CLI log and display them on failure while preserving rollback and exit codes.

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

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 22355

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 22355"

@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

2 / 101 PR test projects · 4 PR jobs, from 4 changed files.

Selected PR test projects (2 / 101)

Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests

Selected PR jobs (4)

cli-starter-validation, extension-e2e, polyglot, typescript-api-compat


How these were chosen — grouped by what changed

📦 affected project Aspire.Cli
→ 1 test: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Cli.Tests/Projects/ProjectUpdaterNuGetConfigurationTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Projects/ProjectUpdaterTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Utils/CliTestHelper.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

Job reasons

Job Triggered by
cli-starter-validation affected project Aspire.Cli
extension-e2e • src/Aspire.Cli/Projects/ProjectUpdater.cs
• affected project Aspire.Cli
polyglot affected project Aspire.Cli
typescript-api-compat affected project Aspire.Cli

Selection computed for commit 9361d8f.

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.

🟢 Approval recommended

No active review issues are reported for the restore-diagnostic improvements.

No open issues 🎉

What changed in this PR

Makes aspire update restore failures easier to diagnose, addressing #22352 without changing DLL-lock handling, rollback behavior, or exit code 13.

Changes:

  • Captures restore stdout and stderr in the CLI log and displays them after the restore status finishes on failure; successful restores remain quiet.
  • Adds regression coverage for project and file-based AppHosts, including logging, failure-only display, and rollback.
  • Documents the behavior and updates test construction for the file-logging dependency.
File Description
tests/​Aspire.Cli.Tests/​Utils/​CliTestHelper.cs Supplies the file logger when constructing the updater.
tests/​Aspire.Cli.Tests/​Projects/​ProjectUpdaterTests.cs Updates existing updater construction sites.
tests/​Aspire.Cli.Tests/​Projects/​ProjectUpdaterNuGetConfigurationTests.cs Adds four restore-diagnostic regression cases.
src/​Aspire.Cli/​README.md Documents restore diagnostic display and logging.
src/​Aspire.Cli/​Projects/​ProjectUpdater.cs Captures restore output and displays it on failure after status completion.

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@JamesNK
James Newton-King (JamesNK) merged commit 164d249 into main Nov 17, 2026
436 of 439 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.1 milestone Nov 17, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #2186

Generated by PR Documentation Check · copilot · auto · 24.4 AIC · ⌖ 1.16 AIC · ⊞ 7.4K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#2186 targeting release/17.0.

Updated aspire-update.mdx to note that restore stdout/stderr is shown (and logged) when the post-update restore fails. Triggered signals: pr_body_has_cli_flag_mention (aspire update --channel staging), pr_body_has_user_facing_section (failure output before/after).

Note

This draft PR needs human review before merging.

David Negstad (danegsta) added a commit that referenced this pull request Nov 18, 2026
…2208)

## Description

`aspire update` now captures native restore diagnostics following
#22355, but those diagnostics can contain credential-bearing feed URLs
that are persisted in the CLI log. This follow-up applies the existing
NuGet redactor before stdout or stderr is buffered or logged, while
preserving useful diagnostics for troubleshooting validation failures.

The redactor uses known sources from candidate and referenced-project
NuGet configurations, plus `RestoreAdditionalProjectSources` values
obtained during project evaluation. Raw evaluation diagnostics are
suppressed so those source properties do not leak through the probes
themselves. Restore diagnostics remain logged for success and failure,
and are displayed only on failure.

The failure summary now includes the channel and project and explicitly
states that the update was not applied.

### Redaction scope

This reuses package-only polyglot restore redaction; it does not scan
diagnostic text for unknown URLs or inspect restore graph files. Sources
introduced only by restore-time targets, additive source changes after
planning, and arbitrary non-source secrets are outside this change's
coverage.

Stacked on #22207. Follows up on #22355. No new dependencies.

### Validation

The following command passed **10/10 cases**, covering project and
file-based AppHosts, successful and failed restores, both output
streams, root and referenced-project sources, evaluated additive
sources, encoded credentials, probe suppression, and candidate feed
configuration:

```shell
dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-method "*.UpdateAsync_RestoreDiagnosticsAreRedactedBeforeLoggingAndFailureDisplay" --filter-method "*.UpdateAsync_DryRunUsesAmbientEvaluationForImportedSdkAndColdCandidateRestore" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"
```

## Checklist

- Is this feature complete?
  - [x] Yes. Ready to ship.
  - [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
  - [x] Yes
  - [ ] No
- Did you add public API?
  - [ ] Yes
    - If yes, did you have an API Review for it?
      - [ ] Yes
      - [ ] No
- Did you add `<remarks />` and `<code />` elements on your triple slash
comments?
      - [ ] Yes
      - [ ] No
  - [x] No
- Does the change make any security assumptions or guarantees?
  - [x] Yes
    - If yes, have you done a threat model and had a security review?
      - [ ] Yes
      - [x] No
  - [ ] No

---------

Co-authored-by: Copilot App <[email protected]>
David Negstad (danegsta) pushed a commit that referenced this pull request Nov 18, 2026
(cherry picked from commit 164d249)

Co-authored-by: Copilot App <[email protected]>
@JamesNK
James Newton-King (JamesNK) deleted the jamesnk/fix-update-restore-diagnostics branch November 19, 2026 11:10
Jose Perez Rodriguez (joperezr) pushed a commit that referenced this pull request Nov 23, 2026
…22219)

Backport of #22182 to release/17.0

Also backports #22207, #22355, and #22208 using their distinct
squash-merge changes, without replaying the stacked PR history.

/cc @danegsta

## Description

C# AppHost updates can ignore configured channels, and failed restores
can block channel updates while hiding actionable diagnostics. Honor
configured channels, separate applying channel updates from `--dry-run`
validation, and log/display native restore diagnostics with best-effort
credential redaction.

Normal channel updates apply confirmed edits without requiring a
validation restore. Explicit `--dry-run` validation uses isolated caches
and restore outputs, then restores the original source files. Updates
without a selected channel retain their existing restore behavior. These
changes do not fix underlying dependency conflicts or MSBuild task DLL
locks.

Relates to #22214 and #22352.

**Release prerequisite:** This backport is intended for 17.0.1.
`release/17.0` still has `PatchVersion=0` although stable v17.0.0 is
published. Advance the release branch to the next unshipped servicing
version in a separate PR; no version bump is included here.

## Checklist

- Is this feature complete?
  - [x] Yes. Ready to ship.
  - [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
  - [x] Yes
  - [ ] No
- Did you add public API?
  - [ ] Yes
    - If yes, did you have an API Review for it?
      - [ ] Yes
      - [ ] No
- Did you add `<remarks />` and `<code />` elements on your triple slash
comments?
      - [ ] Yes
      - [ ] No
  - [x] No
- Does the change make any security assumptions or guarantees?
  - [x] Yes
    - If yes, have you done a threat model and had a security review?
      - [ ] Yes
      - [x] No
  - [ ] No

## Customer Impact

Customers updating C# AppHosts can have their configured channel ignored
or lose candidate updates when dependency conflicts cause restore to
fail, with no useful restore diagnostics. The combined fixes honor the
configured channel, let customers apply channel updates independently of
validation, and expose actionable restore errors. Credential-bearing
package source URLs are redacted on a best-effort basis before
diagnostics are buffered or logged.

## Testing

`./restore.sh` - passed (13 existing package vulnerability warnings, 0
errors).

`git diff --check 38e4ce6..HEAD` - passed. Each of the three added
commits has the same stable patch ID as its source squash commit.

Focused CLI unit run on macOS ARM64 - **788 passed, 2 failed, 2
skipped**:

```shell
MSBUILDTERMINALLOGGER=false dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class '*.ProjectUpdater*' --filter-class '*.UpdateCommand*' --filter-class '*.ConfigSourceCommandTests' --filter-class '*.DotNetAppHostRestorePreviewTests' --filter-class '*.DotNetAppHostUpdateTransactionTests' --filter-class '*.DotNetCliRunnerTests' --filter-class '*.ProcessInvocationOptionsTests' --filter-class '*.NuGetClientTests' --filter-class '*.ProcessExecutionFactoryEnvironmentTests' --filter-class '*.PackageSourceRedactorTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'
```

Both failures were the native file-based restore theory, with
MSB4216/MSB4027 task-host errors caused by mixing the system .NET host
with the repository-local SDK. Rerunning only those cases with the
repository-local host on PATH **passed 2/2**, without code changes:

```shell
PATH="$PWD/.dotnet:$PATH" DOTNET_ROOT="$PWD/.dotnet" MSBUILDTERMINALLOGGER=false .dotnet/dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-method '*.UpdateAsync_FileBasedNativePackageMetadataEditsSourceAndRollsBackOnFailure' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'
```

Across the initial run and targeted retry, all **790 runnable cases
passed**. The two skips require Windows batch execution and a
case-sensitive filesystem, respectively.

E2E scenarios are included in the backport but were not run locally; CI
validation remains outstanding.

## Risk

Medium. This changes when C# channel updates restore and introduces
validation-only rollback and isolated caches/restore outputs. Updates
without a selected channel retain their restore behavior. Credential
redaction is best effort, not a security guarantee; logs should still be
checked before sharing. No supported library API changes or new
dependencies are introduced.

## Regression?

No.

---------

Co-authored-by: David Negstad <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: James Newton-King <[email protected]>
Co-authored-by: David Negstad <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aspire update hides restore errors caused by a lingering MSBuild task DLL lock

3 participants