Reputation: 2121
One of the biggest hurdles when migrating from .NET Framework to .NET 5+ is having to convert all csproj's to the new SDK-style format. There is no tool to automate this, it has to be done manually.
I wonder if this conversion is necessary? Is there a way to switch to .NET while keeping the old cs projects?
With 300+ projects in my team's solution it looks like we are never going to switch. It's just too much work.
I have tried updating the <TargetFramework> manually and that didn't work.
Maybe I'm missing something and there is a way to achieve this?
Upvotes: 3
Views: 1175
Reputation: 517
Not a direct answer to you question but it may help. My goal wasn't to convert to .net 5, just to convert my projects to SDK style.
I have a solution of four .net 4.0 projects including a WPF project and also four xUnit test projects. There is a .net upgrade assistant I used and I just stopped after the "convert project to sdk style step". It worked mostly without issues. I got the idea from this stack overflow post (see comment under accepted answer).
The link above says Visual Studio 2022 or latter but I have 2019 and it worked fine. I think it says that as you'll need 2022 if you are doing the full migration to .net 6/7.
The only other thing I did before converting to SDK was update each project to use PackageReference instead of packages.config. I'm not sure if that's important as I did this before deciding to convert my projects to SDK-style. If you right click on the project you'll see a command called "migrate package.config to package reference". After doing that for all projects then go to Tools > Nuget Package Manager > Package Manager Settings and under Package Manager set the "Default package management format" to PackageReference. See here.
I then converted each project one at a time ensuring each one built OK before moving on to the next project. The only issue I ran into is the migration assistant adds a more recent version of Microsoft.CSharp to each project reference. For my WPF project I had to remove that and replace with the version for .net 4.0; for the other projects I just had to remove it as it wasn't being used. I'm not sure why it does that but thinking it's for a subsequent step in the migration.
The csprojs are now much cleaner. Also enables the "Remove unused references" option in the project right-click menu.
I also confirmed I'm able to use dotnet build myProject.csproj from the command line as well.
Upvotes: 3
Reputation: 3271
Short answer: No, it does not.
Source: https://learn.microsoft.com/en-us/dotnet/core/porting/#considerations-when-porting
[..] the project files for .NET use a different format than .NET Framework, known as the SDK-style project format.
Upvotes: 0