0

.NET Framework 4.8 and .NET 5 Combination Solution

I have 1 Solution in VS2019, with 12 Projects within that Solution. (All C# v.9.0 targeting .NET Framework 4.8) 1 - Main Windows Forms Project And 11 Windows Class Libraries and Database Utilities (Its a legacy app that I have inherited and I don't have the heart to re-write the whole thing)

I want to utilise the wonderful features of C# 9.0 and C# 10.0 (features like immutable records), but I can't do that unless the project targets .NET 5.0

How can I make 1 or 2 projects (Class Libraries) to target .NET 5.0 and leave the rest of the projects targeting .NET Framework 4.8?

I've tried manually altering the .csproj files but VS2019 crashes after I alter the .csproj files.

BTW. I am Using Visual Studio Professional v16.11.3

Jan
  • 1
  • Yeah, it would be *great* if this were possible, but, unfortunately, it isn't. You can make your class libraries .NET standard 2.0 libraries to be able to reference them in .NET 5 and .NET Framework, but then you can't use the C# 10+ goodies either. – Heinzi Sep 17 '21 at 10:15
  • Editing the csproj should be fine - does it work if you do that without it loaded in the IDE? Tips on multi-targeting: https://stackoverflow.com/questions/69220870/cross-framework-project-with-net-core-5-and-net-framework-4-7-2/69220910#69220910 - the language version can be specified using `latest`; some of the features like records *can* be used on lower frameworks, but you need hacks that aren't really worth it in the real world; if your main aim is to use records: honestly : update to .NET 5 or above (if possible) – Marc Gravell Sep 17 '21 at 10:16

0 Answers0