Tools

How to Update a Scaffolded .NET Application Without Overwriting Your Code

ASI Backbone Learning Christopher D. Cavell
Tools

A newer dotnet new template never updates the applications it generated earlier, and regenerating with --force silently deletes customizations while the build stays green. The article scaffolds the old and new template versions separately and reconciles that delta through Git.

Key points

  • dotnet new stops with exit code 73 and lists every file it would overwrite instead of writing.
  • --force replaced Program.cs with the template copy, removing app.MapOrderEndpoints() while the build still passed.
  • A template default that flipped between releases (EnableOpenApi true to false) drops features unless the option is passed explicitly.
  • Files the new template no longer emits, such as StatusEndpoints.cs, stay on disk; forced generation deletes nothing.
  • git apply --index can fail under .gitattributes normalization even when git apply --check succeeds.
  • Regenerate packages.lock.json rather than merging it, and follow EF Core's migration workflow instead of hand-editing.

Why it matters

This hits teams that keep services generated from internal templates alive for years: a new template release looks like an upgrade in the release notes but never touches the application. What changes day to day is discipline — stop treating --force as an upgrade, and write the package version, the feed, every explicit option and the SDK into a manifest at generation time. A green build proves nothing here. The procedure is cheap on one small template and gets expensive across many services and frequent releases; the article is honest about where re-scaffolding costs more than copying. Check that your manifest is actually filled in, not placeholders.

Real-world use

  • A service generated from an internal ASP.NET Core template that has since gained its own endpoints and settings sections.
  • A template release that changes a default option value, such as EnableOpenApi switching from true to false.
  • A repository where packages.lock.json and EF Core migrations must be regenerated rather than hand-merged during a refresh.

This summary was generated by the agent from the original post on ASI Backbone Learning. The full text and all rights belong to its author and publisher. Go to original

Report this story

Is something wrong with the summary, or do you own this content? Your message comes straight to my inbox.

Type of message

Related stories

Feedback

Found a bug or have an idea? Your message lands straight in my inbox.

Type of message