简体   繁体   English

使用特定版本的nuget软件包程序集

[英]Use specific version of nuget package assemblies

I have the following setup: 我有以下设置:

A nuget package with two folders: net45 - including assemblies AssemblyOne.dll and AssemblyTwo.dll netstandard1.3 - including assemblies AssemblyOne.dll and AssemblyTwo.dll Of course these are different files with the same name. 一个带有两个文件夹的nuget程序包:net45-包括程序集AssemblyOne.dll和AssemblyTwo.dll netstandard1.3-包括程序集AssemblyOne.dll和AssemblyTwo.dll当然,这些是具有相同名称的不同文件。

I install the package into a project targeting 4.6.1 version of .NET Framework. 我将软件包安装到目标为.NET Framework 4.6.1版本的项目中。

How can I make sure the assemblies from the netstandard1.3 are added to this project? 如何确定netstandard1.3中的程序集已添加到该项目中? Right now the net45 ones are added. 现在添加了net45。

Thanks! 谢谢!

This is not supported with NuGet. NuGet不支持此功能。 NuGet will take what it considers to be the best match. NuGet将采用认为最合适的方式。

If your project targets .NET Framework then it will consider the assemblies in the NuGet package that also target the .NET Framework to be the best match. 如果您的项目以.NET Framework为目标,则它将认为NuGet程序包中的组件也以.NET Framework为最佳匹配。 In general the more specific the target framework is the one that wins. 总的来说,目标框架越具体,就越成功。

So you are left with either: 因此,您要么选择:

  1. Creating a new NuGet package which does not have the .NET 4.5 assemblies. 创建一个没有.NET 4.5程序集的新NuGet程序包。
  2. Not using NuGet and just extracting the files. 不使用NuGet,而只是提取文件。
  3. Modifying the project afterwards so the assemblies you want to reference are referenced. 之后修改项目,以便引用要引用的程序集。

Another question here is why do you need to reference the .NET Standard assemblies? 这里的另一个问题是,为什么您需要引用.NET Standard程序集?

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM