Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

c# - What is the difference between .net Core multi target and .net Standard?

.Net Standard is used to can be use the same library in different type of projects, such as WPF, xamarin, UWP... etc.

.Net Core can't by default, but there is the possibility to configure the multi target in .net Core editing the csproj file, so I can set multiple targets. In one test that I have done, if I set as target net47, I can use this .net Core library in my WPF project.

So if I can do the same with .net Core multi target and with .net standard. What are the differences and when to use one and when to use other?

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You would need to target multiple frameworks in the csproj file. In the original launch of Visual Studio 2017 there's no UI for this, but you can do it manually. I believe that there will be UI support for this in an update.

It's just a matter of changing the <TargetFramework> element to <TargetFrameworks> and using a semi-colon-separated list of targets. For example, in Noda Time I have:

<TargetFrameworks>net45;netstandard1.3</TargetFrameworks>

You could have:

<TargetFrameworks>netcoreapp1.0;netstandard1.3</TargetFrameworks>

However, you'd only want to do this if you wanted to take advantage (conditionally) of some features that are only available in .NET Core, and not in .NET Standard.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...