Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading large solution to .NET 6

There is some good documentation here how to manually upgrade to .NET 6: https://learn.microsoft.com/en-us/aspnet/core/migration/50-to-60

But I have a large solution with many projects that references many of NuGet-packages that need to be upgraded. Is there any automatic way to do upgrade the project files?

like image 767
PEK Avatar asked Oct 25 '25 04:10

PEK


2 Answers

I used to do it with the "replace-in-files option" and NuGet-Manager in Visual Studio. Worked out for me in a 181 projects solution.

  1. Open any *.csproj-file
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>
</Project>
  1. Press Shift+Ctrl+H enter image description here

  2. Open NuGet-Manager for Solution (not project itself). Select all packages and update them all (if possible, else leave out the once you know are not compatible)

like image 198
Martin Avatar answered Oct 26 '25 20:10

Martin


You can set properties for all projects in the solution using a Directory.Build.props file, see: https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2022#directorybuildprops-and-directorybuildtargets

In your case you'd use something like this:

<Project>
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
  </PropertyGroup>
</Project>

Place the file in the root of your solution, above all project folders.

like image 31
reijerh Avatar answered Oct 26 '25 19:10

reijerh