如何告诉 NuGet 为每个项目安装包而不是解决方案 [英] how to tell NuGet to install package per project and not solution
问题描述
我有一个在不同解决方案中重复使用的类库项目.我希望 NuGet 添加对类库项目的工具包引用,并将其存储在项目文件夹中,而不是在解决方案文件夹中.
示例:
我有
<块引用>D:\Projects\MyClassLibrary
D:\Projects\Solution1
D:\Projects\Solution2
使用 NuGet,我想向 MyClassLibrary 项目添加一个工具包.
现在,如果我打开了 Solution1,NuGet 正在将工具包添加到
<块引用>D:\Projects\Solution1\packages
我想告诉 NuGet 将工具包安装在 MyClassLibrary\packages
文件夹中.
如何做到这一点?
从 nuget 2.1 开始,您可以更改默认的包文件夹位置:
<预><代码><配置><配置><add key="repositoryPath" value="C:\myteam\teampackages"/></config>...</配置>参考:指定包"文件夹位置
-----------------更新-------------------------
您必须启用 nuget 自动包恢复 为解决方案.执行此操作时,请在解决方案根目录中创建一个 .nuget
文件夹.
在该文件夹内有文件 NuGet.Config
,您可以在其中放置此配置.
-----------------(last) UPDATE 2020-------------------------
nuget 已更改,此答案不再适用
I have a class library project which is reused across different solutions. I would like NuGet to add a toolkit reference to the class library project and store it in the project folder not in the solution folder.
Example:
I have
D:\Projects\MyClassLibrary
D:\Projects\Solution1
D:\Projects\Solution2
Using NuGet, I want to add a toolkit to the MyClassLibrary project.
Right now, if I have Solution1 open, NuGet is adding the toolkit to
D:\Projects\Solution1\packages
I would like to tell NuGet to install the toolkit in the MyClassLibrary\packages
folder instead.
How to do this?
You can change the default packages folder location since nuget 2.1:
<configuration>
<config>
<add key=" repositoryPath" value=" C:\myteam\teampackages" />
</config>
...
</configuration>
reference: Specify ‘packages’ Folder Location
-----------------UPDATE-------------------------
you have to enable nuget automatic package restore for the solution.
When you do it nuget create a .nuget
folder in the solution root.
Inside that folder there are the file NuGet.Config
where you can put this configuration.
-----------------(last) UPDATE 2020-------------------------
nuget has changed since and this answer does not apply anymore
这篇关于如何告诉 NuGet 为每个项目安装包而不是解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!