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

查看:30
本文介绍了.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.

这只是将 元素更改为 并使用以分号分隔的目标列表的问题.例如,在野田时间我有:

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天全站免登陆