作为一个概念验证,我想创建一个由单个程序集组成的Nuget包.该程序集使用全新的.NET Standard 1.X配置文件进行编译.我的想法是让它不仅可以通过.NET Core,而且可以从.NET 4.6.1(完整框架),甚至旧版本中使用,但我不知道如何使用.
<?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>
问题是,当将包添加到面向.NET Framework 4.6.1的项目时,它会显示此消息(输出窗口)
Could not install package ‘MyLib X.X.X.X’. 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. For more @R_508_4045@ion,contact the package author.
我该怎么做才能使我的nuget包可用于两个框架(至少.NET Standard 1.X和.NET Framework 4.6.1).
解决方法
你根本不需要你自己的nuspec.
只需创建一个RC 2 project.json,然后使用dotnet pack生成一个NuGet包.
http://dotnet.github.io/docs/core-concepts/libraries/libraries-with-cli.html
您不能指望旧版本的.NET Framework支持此类软件包,因为.NET Standard 1.5版本太高.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。