可以基于框架安装NuGet包吗? [英] Its possible to install NuGet packages based on framework ?

查看:70
本文介绍了可以基于框架安装NuGet包吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以在lib文件夹中保存不同的框架文件夹,如下所示?


├──lib

  ├──netstandard1.2


        ├──装配。 

  ├──netstandard1.4

        ├──组件。



我们能否安装上述结构NuGet软件包安装框架版本?



请提供解决上述问题的任何解决方案?

解决方案

嗨Dheeps,


感谢您在此处发帖。


>>> 可以将不同的框架文件夹保存在lib文件夹中在下面?


当然可以。简单的方法是使用,如果您使用的是VS2017,您可以从
here
。如果您对此方法有任何疑问,可以创建一个关于此方法的新主题,我会继续关注它。



>> ;> 我们能否安装上面结构的基于NuGet包安装的框架版本?


答案是肯定的。
Nuget已经这样做了。
 当NuGet从包安装程序集时,它检查项目的目标.NET Framework版本,然后从
lib 下的相应子文件夹中选择正确的程序集版本。在包中。例如,我创建了一个包含两个框架的包(netstandard1.2和netstandard1.4),



然后我将此软件包安装到Target框架为"netstandard1.4"的测试项目中,NuGet可能是智能的根据项目Target框架将netstandard1.4框架下的dll添加到项目中。



希望这可以给你一些帮助。


Its possible to keep different framework folder inside of lib folder like below?

├── lib
  ├── netstandard1.2

        ├── Assemblies. 
  ├── netstandard1.4
        ├── Assemblies.

Can we able to install above structure NuGet package install based framework version?

Please give any solution to resolve above issue?

解决方案

Hi Dheeps,

Thanks for posting here.

>>>Its possible to keep different framework folder inside of lib folder like below?

Of course you can. The simple method is using the NuGet Package Explorer to create this NuGet package.

Below are detail steps:

1. Download the NuGet Package Explorer and install it.

2. Open NuGet Package Explorer and select "Create a new package (Ctel+N)".

3. Click the "Add" button Ii the drop down menu of the "CONTENT" tab, select "Lib Folder" in the extension of the Add button.

4. Right click "lib" and select "Add .Net Platform Standard folder" and ".NET Platform Stand 1.2".

5. Repeat step 4, select ".NET Platform Stand 1.4

6. Add dll to different framework folder and save it(You can edit the package info at Edit->EditMetadata).Alternatively, you can also use the .nuspec to create that package by add below settings into the .nuspec file:

<files>
    <file src="TestPackage_1.2.dll" target="lib\netstandard1.2" />
    <file src="TestPackage_1.4.dll" target="lib\netstandard1.4" />
</files>

For the detail steps, you can refer to this document, if you are using VS2017, you can get the help from here. If you have any question about this method, you can create a new thread about it, I will keep follow it.

>>>Can we able to install above structure NuGet package install based framework version?

The answer is yes. Nuget is already doing that. When NuGet installs an assembly from a package, it checks the target .NET Framework version of the project, then selects the correct version of the assembly from the appropriate subfolder under lib in the package. For example, I have created a package with two frameworks (netstandard1.2 & netstandard1.4),

then I install this package to the test project which Target framework is "netstandard1.4", NuGet could be smart to add the dll under the framework netstandard1.4 to the project based on the project Target framework.

Hope this can give you some help.


这篇关于可以基于框架安装NuGet包吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆