Repository navigation
[dotnet] Remove stale template packs when installing. Fixes #26540. - #26551
Conversation
Delete older versioned template packages before copying the current package into the local SDK, and assert that generated projects target the current .NET TFM. Fixes #26540 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 922cac8a-9067-4219-943b-fbbc9e19c6ad
There was a problem hiding this comment.
🟢 Approval recommended
The changes directly address the reported template-pack duplication issue and add a targeted regression check; remaining feedback is limited to improving test diagnostics.
Pull request overview
This PR fixes incremental SDK install behavior where multiple versions of the same Apple template pack could accumulate, leading dotnet new to pick an older template (and thus generate projects targeting an older .NET TFM). It also strengthens the existing template tests to assert that generated projects target the repository’s current Configuration.DotNetTfm.
Changes:
- Remove previously installed
Microsoft.<platform>.Templates.*.nupkgfiles before copying the current template pack into the local SDK’stemplate-packsdirectory. - Add a regression assertion in template tests to verify the generated project’s
<TargetFramework>matchesplatform.ToFramework (Configuration.DotNetTfm).
File summaries
| File | Description |
|---|---|
| tests/dotnet/UnitTests/TemplateTest.cs | Adds an assertion to ensure generated templates target the current .NET TFM. |
| dotnet/Makefile | Deletes stale template-pack .nupkg versions during install to prevent template identity duplication. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #32f4b9b] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 264 tests passed 🎉 Tests counts✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
Incremental installs copied each new versioned template package into the local SDK without removing older versions. This left duplicate template identities in the template engine cache, which could cause
dotnet newto select a package targeting an older .NET TFM.Remove previous versions of each platform's template package before installing the current one. Also assert in the template tests that every generated project targets the current
Configuration.DotNetTfm.Fixes #26540
🤖 Pull request created by Copilot