Fix template restores using the repository SDK - #20166
Ankit Jain (radical) wants to merge 5 commits into
Conversation
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>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 20166Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 20166" |
There was a problem hiding this comment.
🟡 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.
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>
There was a problem hiding this comment.
🟢 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>
There was a problem hiding this comment.
🟡 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.
…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>
There was a problem hiding this comment.
🟢 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.
|
[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. |
Description
Internal template tests failed when isolated .NET 8, 9, or 10 SDKs ran template restore post-actions.
The test process inherited
MSBuildExtensionsPathfrom 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
MSBuildExtensionsPathandMSBuildSDKsPathcase-insensitively from both template command and AppHost child processes. Abasic-buildregression 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'partiallySucceededresult came from unrelated auto-injected supply-chain analysis warnings.Refs #18381
Checklist
<remarks />and<code />elements on your triple slash comments?