简体   繁体   English

.NET标准NuGet跨平台兼容性

[英].NET Standard NuGet cross platform compatibility

I am looking into a way to create a NuGet package that can be consumed by a .NET 4.5.1+ and .NET Core 1.0+ applications. 我正在寻找一种创建可以由.NET 4.5.1+和.NET Core 1.0+应用程序使用的NuGet程序包的方法。 Should I be able to use .NET standard 1.0 framework? 我应该能够使用.NET标准1.0框架吗? Would it matter if this NuGet solution I am building had a dependency on a .NET Core NuGet? 我正在构建的此NuGet解决方案是否依赖于.NET Core NuGet会不会很重要? Does that make sense? 那有意义吗?

Should I be able to use .NET standard 1.0 framework? 我应该能够使用.NET标准1.0框架吗?

It might be easier to multi-target; 多目标可能更容易; you can use <TargetFrameworks>net451;netstandard1.0</TargetFrameworks> or similar to do that in the .csproj; 您可以使用<TargetFrameworks>net451;netstandard1.0</TargetFrameworks>或类似方法在.csproj中执行此操作; but: .NET 4.5.1 (net451) supports .NET Standard 1.2 and below, so 1.0 should be fine. 但是:.NET 4.5.1(net451)支持.NET Standard 1.2和更低版本,因此1.0应该很好。

Would it matter if this NuGet solution I am building had a dependency on a .NET Core NuGet? 我正在构建的此NuGet解决方案是否依赖于.NET Core NuGet会不会很重要?

.NET Core is a framework, not a standard; .NET Core是一个框架,而不是一个标准; normally, it is applications (exes) that target .NET Core - libraries target .NET standard. 通常,面向.NET Core的是应用程序(exes)-面向.NET标准的库。

I am looking into a way to create a NuGet package that can be consumed by a .NET 4.5.1+ and .NET Core 1.0+ applications. 我正在寻找一种创建可以由.NET 4.5.1+和.NET Core 1.0+应用程序使用的NuGet程序包的方法。 Should I be able to use .NET standard 1.0 framework? 我应该能够使用.NET标准1.0框架吗?

Use this table in order to find out if a particular framework implements some version of .NET Standard. 使用此表可以确定特定框架是否实现了某些版本的.NET Standard。

.Net Framework 4.5.1 implements up to v1.2 so the answer to your question is "yes" - you can use v1.0. .Net Framework 4.5.1最多可实现v1.2,因此您问题的答案为“是”-您可以使用v1.0。 However, make sure v1.0 has a sufficient API. 但是,请确保v1.0具有足够的API。

Speaking of @MarcGravell's comment 谈到@MarcGravell的评论

It might be easier to multi-target; 多目标可能更容易;

I would say you shouldn't do that unless you have executable applications rather than shared class library. 我要说的是除非拥有可执行的应用程序而不是共享的类库,否则不应该这样做。 Always strive to use .NET Standard for a class library project. 始终努力将.NET Standard用于类库项目。

Would it matter if this NuGet solution I am building had a dependency on a .NET Core NuGet? 我正在构建的此NuGet解决方案是否依赖于.NET Core NuGet会不会很重要? Does that make sense? 那有意义吗?

There's no need to add any other runtime dependencies once you target .NET Standard or .NET Core. 一旦以.NET Standard或.NET Core为目标,就无需添加任何其他运行时依赖项。 All of those will be added implicitly and will be mentioned within deps.json file. 所有这些都将隐式添加,并将在deps.json文件中提及。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NuGet 恢复失败 - .NET 7.0 与 .NET 标准 2.0 的兼容性 - NuGet Restore Fails - .NET 7.0 compatibility with .NET Standard 2.0 .NET十进制跨平台标准 - .NET decimal cross-platform standard 在 .NET Standard 跨平台应用程序中安全地存储密钥 - Store secret key securely in .NET Standard cross-platform app .NET(标准,核心和框架):开发跨平台应用程序 - .NET (standard, Core and Framework): Developing Cross Platform Applications 标准.NET XML序列化程序的替代方法,适用于跨平台通信 - An alternative to the standard .NET XML serializer, suitable for cross platform communication .NET标准Nuget参考 - .NET Standard Nuget References NuGet 包的向后 .NET 兼容性? - Backward .NET compatibility for NuGet packages? 如何以编程方式找到 nuget 包安装文件夹? (.NET Core - 跨平台) - How can I find nuget package installation folder programmaticaly ? (.NET Core - Cross Platform) 什么是组织.NET跨平台开发的Visual Studio项目和代码的行业标准方法 - What's the industry standard way to organize Visual Studio projects and code for .NET Cross-platform development .NET平台标准中的平台是什么? - What are the platforms in the .NET Platform Standard?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM