Can the .NET 5 SDK be used to compile .NET Core 3.1 projects?

Viewed 1143

We are starting a new project with .NET 5. The build server has the .NET Core 3.1 SDK installed. I was planning to also install the .NET 5 SDK side by side on the same server. Can I remove the .NET Core 3.1 SDK and use .NET 5 to compile both types of projects?

2 Answers

Yes the .NET 5 SDK can and will readily compile .NET Core 3.1 projects. You need to set <TargetFramework> appropriately. It's very easy to make a mistake and use later language features if you don't set <LangVersion> but the resulting binaries will run using .NET Core 3.1.

The references might not be there, but if they're not there they will be fetched by dotnet restore just fine.

There was no need to remove .NET Core 3.1. After installing .NET 5 a new SDK subfolder was added and existing SDK folder for 3.1 was left. Now projects for either SDK version can be built on the server.

Related