How to increase .Net version from 5 to 9 in existing project
Loading
How to increase .Net version from 5 to 9 in existing project
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rajesh GamiPosted Dec 2, 2025, 12:07 PM
Pre-Upgrade Checklist & Preparations
Before you start changing things:
Back up your solution / ensure version control — commit all changes, tag the stable baseline. This ensures you can roll back if something breaks.
Check all dependencies / NuGet packages — list all third-party NuGet (or internal) packages your project uses. You’ll need to verify whether each has a version compatible with .NET?9, or an alternative.
Inventory your project types — e.g. are you using Web (ASP.NET), Console, WinForms, WPF, mobile (MAUI), libraries, etc. This matters because some project types may need extra attention when upgrading.
If you use global.json or explicit SDK locking, check that it’s ready to reference .NET 9 SDK. Otherwise you might end up building with an older or unintended SDK version.
?? Upgrade Process (Step-by-Step)
Here’s a recommended upgrade procedure (similar to what’s used in official guidance with tools + manual changes).
Install .NET 9 SDK (and update dev environment / build agents)
On your development machine (and on any CI/CD or build servers), install the .NET?9 SDK.
If you use a
global.jsonto control SDK version, update it to point to the 9.x SDK. For example:Use .NET Upgrade Assistant — or manual approach
The .NET Upgrade Assistant (either via command-line or Visual Studio extension) can guide much of the upgrade. It analyzes your projects, dependencies and suggests what needs to change. Microsoft for Developers+1
From CLI, you may run:
and follow interactive prompts (select target framework, projects, etc.). Microsoft Learn+1
If you prefer manual: open the
.csproj(or equivalent) files and update the(or) from e.g.net5.0tonet9.0. Microsoft Learn+1Restore & update NuGet packages / dependencies
After changing the target framework, restore packages (
dotnet restore) and then update all packages to versions that support .NET 9. Some packages may drop support or require alternate versions.For packages that don’t support .NET 9, you may need to replace them or accept workarounds. The Upgrade Assistant helps by flagging incompatible dependencies. Microsoft for Developers+1
Rebuild the solution / projects — resolve compile errors
Build all projects (in correct dependency order). If you have multiple projects (libraries, web, services) — upgrade lower-level (libraries / shared) first, then higher-level depending projects. Microsoft Learn+1
Fix any compile-time errors, e.g. removed or changed APIs, changed behavior, configuration differences, etc.
Update platform-specific settings (if any)
If you use platform-specific targets (e.g. mobile / Android / MAUI, or platform-specific settings), ensure the
is correctly set (for examplenet9.0-android35if applicable) and update related settings. SilverPC Blog+1Also, in case of MAUI or similar workloads, ensure workloads are installed (
dotnet workload install …) and build pipelines / agents updated accordingly. Medium+1Test thoroughly — unit, integration, end-to-end, manual flows
Run all existing unit tests and integration tests. Ensure they pass.
Perform smoke tests / manual testing for all critical application flows (UI, API, background jobs, etc.).
If you have CI/CD pipelines — update pipeline definitions to use .NET 9 SDK and ensure builds & deployments still succeed.
Review breaking changes / API removals / behavioral changes
Refer to the official “breaking changes” documentation for .NET, to check whether any APIs or behaviors your code relies on have changed or been removed. Microsoft Learn+1
For any such potential issues, make necessary code modifications or find replacements.
Update documentation / configs / deployment scripts / pipelines
Update README / docs to reflect new .NET version.
Update any deployment / build / Docker / container / CI/CD pipeline to use .NET 9.
If you use global.json, SDK version pinning, ensure those are updated.
Smoke-release / staging — then production release
Deploy first to a staging or test environment. Monitor for regressions (functional, performance, security).
Only after confidence — release to production.
Rajesh GamiPosted Dec 2, 2025, 12:07 PM
What to Watch Out For / Common Pitfalls
Some third-party NuGet packages might not yet support .NET 9 (or their latest versions might drop support). That may cause runtime issues or force you to find alternatives.
There may be breaking changes between .NET 5 ? .NET 9 (especially across major version jumps) — some APIs might be removed or behavior might change. Microsoft Learn+1
If your solution has many projects / dependencies, upgrade order matters: libraries first, then consumer projects — otherwise you may face build dependency issues. Microsoft Learn+1
If you have custom build pipelines / CI/CD agents — these need to be updated (SDK version, workloads, build commands).
For specialized project types (e.g. MAUI, mobile, desktop), platform-specific settings or workloads may need additional verification.
Recommended Strategy (Given Modern Project & .NET 5 Base)
Given that you’re already on .NET 5 and presumably using modern SDK-style projects — the easiest and safest approach is:
Branch your code (e.g. create a
upgrade/net9branch).Use .NET Upgrade Assistant to get an initial automated upgrade.
Update SDK, TargetFramework, restore packages, build ? fix compile errors.
Run full test suite + manual smoke testing.
Upgrade build pipelines / deployment configs.
Deploy to staging, then to production once validated.
This reduces manual effort (thanks to the automated tool) while giving you checkpoints and rollback options.