Skip to content

[dotnet] Remove stale template packs when installing. Fixes #26540. - #26551

Merged
rolfbjarne merged 1 commit into
mainfrom
dev/rolf/issue-26540
Sep 3, 2026
Merged

rolfbjarne merged 1 commit into
mainfrom
dev/rolf/issue-26540

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

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 new to 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

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
Copilot AI lite review requested due to automatic review settings September 3, 2026 05:37

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 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.*.nupkg files before copying the current template pack into the local SDK’s template-packs directory.
  • Add a regression assertion in template tests to verify the generated project’s <TargetFramework> matches platform.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

Comment thread tests/dotnet/UnitTests/TemplateTest.cs Resolved
@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 32f4b9bd6961144d7d9def785863bb20dcee674a [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [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
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 7 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 31 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 31 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 31 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 25 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 25 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 20 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 25 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

✅ Linux build succeeded

Pipeline on Agent
Hash: 32f4b9bd6961144d7d9def785863bb20dcee674a [PR build]

@rolfbjarne
rolfbjarne merged commit 74da6f9 into main Sep 3, 2026
55 checks passed
@rolfbjarne
rolfbjarne deleted the dev/rolf/issue-26540 branch September 3, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot ready-to-review This PR is ready to review/merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dotnet new selects an older TFM for Apple project templates

4 participants