简体   繁体   中英

How can a .Net 5 Visual Studio Project / Solution that reference a .Net Core 3.1 NuGet package compile successfuly?

Right to the point:

How can my Visual Studio Solution / Project written in.Net 5 successfully compile and run when it references a.Net Core 3.1 NuGet Package?

More Detail

I had a Visual Studio solution with multiple projects. All written in.Net Core 3.1 with the target framework of netcoreapp3.1. See below.

<TargetFramework>netcoreapp3.1</TargetFramework>

I upgraded all of the project to.Net 5, with a target framework of net5.0 See below.

 <TargetFramework>net5.0</TargetFramework>

I had to upgrade all of them, even the ones that only have POCO classes. If not, the solution would not compile, which makes sense to me.

My Solution references 2 NuGet packages. Written by another developer in my company. Who is not with us anymore.

One of the packages is written in.Net Standard. I complete understand why I have no problems with that package. It uses the below target framework.

<TargetFramework>netstandard2.1</TargetFramework>

However, the other package is uses target framework netcoreapp3.1. (I have access to the source code.)

My solution complies and runs fine locally. I don't understand how this is possible.

Why did I have to upgrade all of my project within my solutions to.Net 5. But, the package did not have to be upgraded. I was all prepared to upgrade it.

Was it packaged a special way?

Any inside would be helpful.

I am just trying to understand this.

You should note that NET5.0 is a new release of Net Core Sdk rather than the traditional Net Framework . See this similar issue and this official document .

That upgrade your project from Net Core 3.1 into Net5.0 is an upgrade of the same type of SDK version.

And the higher version of the Net Core sdk is compatible with the lower version of the sdk. So you do not have to worry about upgrading the nuget packages of Net Core 3.1 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM