.net Core多目标和.net Standard有什么区别? [英] What is the difference between .net Core multi target and .net Standard?

查看:128
本文介绍了.net Core多目标和.net Standard有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.Net Standard过去可以在不同类型的项目中使用同一库,例如WPF,xamarin,UWP等。

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

.Net Core无法默认设置,但是可以在.net Core中配置多目标以编辑csproj文件,因此我可以设置多个目标。在我完成的一项测试中,如果将目标设置为net47,则可以在WPF项目中使用此.net Core库。

.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.

因此,如果我可以执行相同的操作.net Core多目标和.net标准。有什么区别,何时使用一个以及何时使用另一个?

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?

谢谢。

推荐答案

您需要在csproj文件中定位多个框架。在Visual Studio 2017的最初发布中,没有为此提供UI,但是您可以手动进行操作。我相信在更新中将对此提供UI支持。

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.

只需更改< TargetFramework> 元素添加到< TargetFrameworks> 并使用以分号分隔的目标列表。例如,在Noda Time中,我有:

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>

您可能会:

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

但是,如果您想(有条件地)利用某些东西,就只想这样做这些功能仅在.NET Core中可用,而在.NET Standard中不可用。

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.

这篇关于.net Core多目标和.net Standard有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆