Skip to content

Fix template restores using the repository SDK - #20166

Closed
Ankit Jain (radical) wants to merge 5 commits into
microsoft:mainfrom
radical:ankj/fix-internal-build-3072363
Closed

Ankit Jain (radical) wants to merge 5 commits into
microsoft:mainfrom
radical:ankj/fix-internal-build-3072363

Conversation

@radical

@radical Ankit Jain (radical) commented Sep 16, 2026

Copy link
Copy Markdown
Member

Description

Internal template tests failed when isolated .NET 8, 9, or 10 SDKs ran template restore post-actions.

D:\a\_work\1\s\.dotnet\sdk\11.0.100-rc.1.26425.128\NuGet.targets(200,5): error : Could not load file or assembly 'System.Runtime, Version=11.0.0.0'
Restore failed.
Post action failed.

The test process inherited MSBuildExtensionsPath from the repository build. That property continued to point at the repository's .NET 11 SDK, so nested restores loaded .NET 11 targets even though the template command used an isolated older SDK.

Remove inherited MSBuildExtensionsPath and MSBuildSDKsPath case-insensitively from both template command and AppHost child processes. A basic-build regression test poisons both parent SDK paths and queries the child process's resolved MSBuild paths from outside the repository, so this scenario runs in PR CI without adding another split test work item.

Validation:

  • dotnet test --project tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj --no-launch-profile -- --filter-method '*.ChildDotNetProcessesDoNotInheritParentSdkPaths' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'
  • Reduced internal pipeline build 3077250: template tests passed.
  • Full internal pipeline build 3077272: template tests passed with no failed jobs. The overall partiallySucceeded result came from unrelated auto-injected supply-chain analysis warnings.

Refs #18381

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

Template post-actions inherited MSBuildExtensionsPath from the repository
build. That property pointed at the .NET 11 SDK and forced nested restores
from isolated .NET 8, 9, and 10 template tests to load the .NET 11
NuGet.targets, which failed with a missing System.Runtime,
Version=11.0.0.0 assembly.

Remove inherited MSBuild SDK paths when creating child template processes.
Add a basic-build regression test that poisons both parent SDK paths and
verifies neither reaches the child process.

Refs microsoft#18381

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@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 -- 20166

Or

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

@github-actions github-actions Bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Sep 16, 2026
@aspire-repo-bot
aspire-repo-bot Bot requested a balanced review from Copilot September 16, 2026 03:49

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.

🟡 Changes recommended

The Fixes #18381 reference would incorrectly close an unrelated source-indexing timeout issue.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Prevents isolated template SDK processes from inheriting repository SDK paths.

Changes:

  • Removes inherited MSBuild SDK paths from child processes.
  • Adds regression coverage for both variables.
File summaries
File Description
tests/Shared/TemplatesTesting/ToolCommand.cs Clears repository SDK paths.
tests/Aspire.Templates.Tests/DotNetCommandTests.cs Verifies child-process isolation.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced (auto)

Note

Copilot is running an experiment and ran this review at Balanced.


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/Aspire.Templates.Tests/DotNetCommandTests.cs Outdated
ProcessStartInfo environment matching is case-sensitive on Unix, so
removing only canonical variable names could leave differently-cased SDK
path overrides intact. AppHost launches also created their own process
environment and bypassed the cleanup.

Remove inherited SDK path variables case-insensitively through a shared
helper used by both child-process paths. Strengthen the regression to
query the child MSBuild properties from a temporary working directory,
and keep it in the existing basic-build test class to avoid creating
another split CI work item.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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

The environment cleanup is correctly applied and backed by focused cross-platform regression coverage.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced (auto)

Note

Copilot is running an experiment and ran this review at Balanced.

Poison the canonical MSBuild SDK path variables so the test proves the
child MSBuild process resolves against the selected SDK on every
platform. Also include alternate-casing variants and verify they are
removed, covering Unix's case-sensitive process environment.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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.

🟡 Changes recommended

The AppHost cleanup path lacks focused regression coverage.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Balanced (auto)

Note

Copilot is running an experiment and ran this review at Balanced.

Comment thread tests/Shared/TemplatesTesting/AspireProject.cs
…ld-3072363

# Conflicts:
#	tests/Aspire.Templates.Tests/NewUpAndBuildStandaloneTemplateTests.cs
The existing regression exercised the ToolCommand process path but did
not fail if AspireProject stopped sanitizing its separately-created
AppHost process.

Capture the AppHost ProcessStartInfo immediately before launch and verify
that inherited MSBuild SDK paths were removed. Keep the test on the
standalone template test class after the upstream class split so it runs
once instead of being inherited by every derived test class.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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

The focused fix covers both affected child-process paths with appropriate regression tests.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced (auto)

Note

Copilot is running an experiment and ran this review at Balanced.

@radical
Ankit Jain (radical) marked this pull request as ready for review September 17, 2026 23:15
@radical

Copy link
Copy Markdown
Member Author

[automated] Closing because the production fix is already on main. The remaining diff only changes test code and test infrastructure, so this PR is no longer needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants