Upgrade a .NET Framework 4.8 plugin to .NET Core in Visual Studio?

Is there a way to actually upgrade a Grasshopper plugin built upon a .NET Framework 4.8 Visual Studio template to use also .NET Core?

So far, I’ve read the following guides and threads:

All of them suggest a new project using the updated template, either as a starting point or as an added launcher for debugging in Rhino 8 (which I’ve done, but that’s not what I want). I’ve not yet seen a way of actually upgrading a .NET Framework 4.8 project to use also .NET Core. I’m talking about a project whose properties in Visual Studio still look like this:

If I click on “Install other frameworks…” I just get redirected to this site, but nothing changes even after installing the SDK libraries. Of course, .NETCore SDK libraries are already installed on my PC (both 7.0 and 8.0).
I’ve tried to use multiple <TargetFrameworks> in the .csproj file as CSykes suggests here: in my .csproj file there is a <TargetFrameworkVersion>v4.8</TargetFrameworkVersion> line, and if I try to replace it with <TargetFrameworks>net4.8;net8.0</TargetFrameworks> I get an error code 0x80004002 in the solution, and the solution itself is not loaded.

So, is there an actual way to upgrade an old 4.8 project to use also .NET Core? Or is starting from a new, updated template the only way? If so, how can I preserve the old plugin GUID so that it is effectively a new version and the new version does not install in parallel with the old one? Or maybe I just missed something along the way?

@curtisw @CallumSykes tagging you as the authors of the “Moving to .NET Core” page, maybe you can provide some insight on my question (I think my post went under the radar….).

There’s no real difference between a netfx project and a netcore project.

After you change it (and all your other .csproj’s) you’ll also need to clear your bin and obj folders, then try a full rebuild. If that still has errors, copy them into this thread and we’ll take another look.

1 Like

Hey @ale2x72,

The usual way to migrate older .NET framework projects is to first convert it to an sdk-style project.

To do this manually, here are many changes that you’d need to do the the .csproj other than just changing <TargetFrameworkVersion> to <TargetFrameworks>, such as removing other properties, imports, changing the header, etc.

You might want to take a look at the .NET Upgrade Assistant, which is the official MS tool to help do this. It usually does a good job, but there may be other minor tweaks you need to do after it has updated your project.

Hope this helps.

1 Like

Just a note, .NET Upgrade Assistant is a legacy package. Latest Visual Studio versions have it built in, but it is hidden under “Legacy” setting in Modernize section of options, because M$ is pushing its new Modernize tools using Copilot requiring Copilot subscription.

3 Likes

Thanks everyone, these were all very helpful suggestions!

@mlukasz87 Thank you in particular for your note! In my search for solutions, I did find the suggestion to use the .NET Upgrade Assistant, but I hit a snag when I saw Microsoft discontinued it in favor of Copilot (burying it in the Legacy settings…. jeez…).

Long story short, I was able to upgrade the project using the .NET Upgrade Assistant, plus a few post-upgrade adjustments (also comparing the result with a new test solution). In case this might help others, here’s what I had to do:

  • the upgrade assistant migrated to .NET Standard 2.0, so I just had to change that using the <TargetFrameworks>net4.8;net8.0</TargetFrameworks> instruction in the project file
  • when building the solution, the output plugin file is saved as .dll (not .gha), with an error in post-build events instructions. To fix this, I removed those instructions and added <TargetExt>.gha</TargetExt> to the .csproj file
  • I created the two debug launch profiles for Rhino 8 netcore and netfx based on the brand-new test solution

For now, everything seems to work fine, thank you all again!

1 Like