.NET 8 upgrade

.NET 8 upgrade

Today I decided it was time to upgrade one of our @dotnet projects from .NET7 to .NET8. The previous .NET 6 to 7 upgrade was pretty smooth, in contrast to .NET 3.x to 5 and 5 to 6 for instance. Normally I upgrade a solution by hand by editing csproj, prop and package files. We learned from the past, so we use central package management and custom msbuild files in most of our solutions to make migrations and NuGet package upgrades easier.

Typical MsBuild files

As a first step I wanted to do a quick search and replace. Find net7.0 in all csproj files and replace it with net8.0.

 <TargetFramework>net7.0</TargetFramework>        

That should work, right? When I load the solution in Visual Studio 2022 (17.8), the NuGet solution explorer doesn't recognize any of the solution NuGet packages: the Installed and Update tabs are empty.

Let's try something else and revert the changes. There is a global dotnet upgrade tool. There is also a VS extension, but I rather want to use a command-line tool for this type of migration. When I run the command-line tool, I see I have to convert project by project. That's not ideal. After trying out one project upgrade I see it ignores central package management and adds package versions to all dependencies. That's not what I want!

OK, forget about tooling and revert the changes. I'm going to edit the project files and package change versions myself. Voilà, it works and now VS picks up additional NuGet package updates. It's really easy to do.

In the meantime I'm working on another bug in my PR-branch with the .NET7 runtime. Switching branches while the solution is loaded and switching between .NET7 and .NET8 is still not a good idea: I hear my fan blowing while VS stops working. The recommended approach for me is to unload the solution, change branches and reload the solution. It's not a big deal and this problem is often temporarily.

Once you have a .NET8 solution it's really taking care of build warnings and potential runtime issues. For me the code upgrade was pretty smooth afterwards. There are some nice analyzer warnings like [Breaking change]: Legacy serialization infrastructure APIs marked obsolete · Issue #34893 · dotnet/docs · GitHub and those are easy to fix.

The solution runs fine on .NET8 and deploying to Azure has no unpleasant surprises. I'm using Terraform for provisioning the infrastructure and it only reports the .NET runtime change and that's fine. One funny note: Azure App Services report .NET8 as .NET 8 (LTS) (Early Access).

Go ahead and upgrade your .NET solution!

Links:

- https://learn.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-overview

- https://github.com/dotnet/upgrade-assistant

- https://devblogs.microsoft.com/nuget/introducing-central-package-management/

- https://learn.microsoft.com/en-us/dotnet/core/tools/global-json

- https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-your-build


Dennis Wals

De directie stelt zich niet aansprakelijk voor verloren overtuigingen of beschadigde heilige huisjes

1 年
回复

要查看或添加评论,请登录

Theo Albers的更多文章

  • Tussenstand 2020

    Tussenstand 2020

    Het is vandaag Bevrijdingsdag en daarom laat ik los. Ik laat los dat we begin januari een reis naar Thailand boeken…

    3 条评论
  • Oracle Soar to the Cloud...

    Oracle Soar to the Cloud...

    We all know upgrading a standard ERP implementation is hard, because of the unique integrations and customizations…

    1 条评论
  • Cross platform Edge?

    Cross platform Edge?

    After having installed W10 Fall Creators Update and Edge on Android, I gave continuum a spin. Soon I raised my eyebrows…

  • Mobile development, business decides

    Mobile development, business decides

    Once the business has identified the need to deliver functionality on mobile devices, the next question emerges: how…

  • Internet of Things - beveiliging

    Internet of Things - beveiliging

    Je wordt op een morgen wakker en dan is het zover: ook bij jou wordt het stuur plus airbag uit je auto gestolen. Ik…

  • SDK + Developer != AI

    SDK + Developer != AI

    IBM Watson, Microsoft Azure Machine Learning, Amazon Machine Learning, Google Cloud Machine Learning, er is geen tekort…

    1 条评论
  • Would I buy the Surface Book again?

    Would I buy the Surface Book again?

    November 2015, getting ready for my trip to Redmond. Last check: do they have the Surface Book in stock at the…

    6 条评论
  • Refactoring or gaining insight?

    Refactoring or gaining insight?

    Most developers have a natural resistance to appreciate someone else's code. This is especially true when developers…

  • Abstractions

    Abstractions

    How long until Google Translate For Programming Languages takes over? Here https://elementscompiler.com/elements/silver/…

    1 条评论

社区洞察

其他会员也浏览了