简体   繁体   English

使用NET Standard 1.X的Nuget包

[英]Nuget package with NET Standard 1.X

As a proof-of-concept, I would like to create a Nuget package that consists of a single assembly. 作为一个概念验证,我想创建一个由单个程序集组成的Nuget包。 This assembly is compiled using the brand new .NET Standard 1.X profile . 该程序集使用全新的.NET Standard 1.X配置文件进行编译。 My idea is to make it usable not only by .NET Core, but also from .NET 4.6.1 (full framework), or even older versions, but I don't know how. 我的想法是让它不仅可以通过.NET Core,而且可以从.NET 4.6.1(完整框架),甚至旧版本中使用,但我不知道如何使用。

For the moment, I created a nuspec file that looks like this: 目前,我创建了一个nuspec文件:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
  <metadata>

    <id>MyPackage</id>
    <description>MyPackage</description>

    <version>X.X.X.X</version>
    <authors>JMN</authors>
    <owners>JMN</owners>
    <licenseUrl>http://opensource.org/licenses/Apache-2.0</licenseUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>

  </metadata>

  <files>
    <file src="bin\Release\MyLib.dll" target="lib\netstandard1.X\MyLib.dll" />
  </files>

</package>

The problem is that, when adding the package to a project that targets .NET Framework 4.6.1, it says this message (output window) 问题是,当将包添加到面向.NET Framework 4.6.1的项目时,它会显示此消息(输出窗口)

Could not install package 'MyLib XXXX'. 无法安装包'MyLib XXXX'。 You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.1', but the package does not contain any assembly references or content files that are compatible with that framework. 您正在尝试将此软件包安装到以“.NETFramework,Version = v4.6.1”为目标的项目中,但该软件包不包含与该框架兼容的任何程序集引用或内容文件。 For more information, contact the package author. 有关更多信息,请与软件包作者联系。

What should I do to make my nuget package usable for both Frameworks (at least both .NET Standard 1.X and .NET Framework 4.6.1). 我该怎么做才能使我的nuget包可用于两个框架(至少.NET Standard 1.X和.NET Framework 4.6.1)。

You don't need your own nuspec at all. 你根本不需要你自己的nuspec。

Simply create an RC 2 project.json and then use dotnet pack to generate a NuGet package. 只需创建一个RC 2 project.json,然后使用dotnet pack生成一个NuGet包。

http://dotnet.github.io/docs/core-concepts/libraries/libraries-with-cli.html http://dotnet.github.io/docs/core-concepts/libraries/libraries-with-cli.html

You cannot expect older versions of .NET Framework to support such package, as .NET Standard 1.5 is too high a version. 您不能指望旧版本的.NET Framework支持此类软件包,因为.NET Standard 1.5版本太高。

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

相关问题 Elasticsearch 1.x应该使用哪个版本的NEST NuGet包? - Which version of NEST NuGet package should be used with Elasticsearch 1.x? NuGet 包 (.NET Standard 2.x) 破坏 ASP.NET MVC5 应用程序(.NET 完整框架) - NuGet package (.NET Standard 2.x) breaking ASP.NET MVC5 application (.NET full framework) 适用于CRM REST的.NET Standard 2.0 Nuget软件包 - .NET Standard 2.0 Nuget package for CRM REST 自定义.NET Standard Nuget软件包无法正确安装 - Custom .NET Standard Nuget package not installing correctly 适用于.NET Standard 1.x的Type.GetInterfaces()变通方法 - Type.GetInterfaces() workaround for .NET Standard 1.x 在.NET Core Web API中安装自定义.NET Standard NuGet软件包 - Install custom .NET Standard NuGet Package in .NET Core Web API 无法为 NET Standard 加载 NuGet 包的文件或程序集异常 NET 5/6 - could not load file or assembly exception NET 5/6 of NuGet package for NET Standard 如何将 .Net Standard Nuget 包添加到 .Net 4.5 Framework 项目中? - How to add .Net Standard Nuget package into .Net 4.5 Framework Project? 从.Net Standard项目和本机dll创建nuget包 - Create a nuget package from .Net Standard project and Native dlls 将文本模板(* .tt)包含在.NET Standard NuGet包中 - Including Text Template (*.tt) into the .NET Standard NuGet Package
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM