是否可以更改 NuGet 包的位置? [英] Is it possible to change the location of packages for NuGet?

查看:40
本文介绍了是否可以更改 NuGet 包的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的大部分项目都有以下约定:

/src/解决方案.sln/解决方案文件夹/项目1/项目2/等等../lib/起订量最小起订量.dll许可证.txt/Yui-压缩机yui.compressor.dll/工具/IL合并应用程序

您会注意到我没有将外部库放在源文件夹中.我也对使用 NuGet 非常感兴趣,但不希望在源文件夹中使用这些外部库.NuGet 是否有更改所有包加载到的目录的设置?

解决方案

现在可以控制软件包安装到哪个文件夹中.

http://nuget.codeplex.com/workitem/215

请参阅 Phil Haack 于 2010 年 12 月 10 日晚上 11:45 发表的评论(在工作项目/上面的链接中).该支持在 1.0 中部分实现,但没有记录.

根据@dfowler 的说法:在解决方案旁边添加一个 nuget.config 文件:

<repositoryPath>{这里有一些路径}</repositoryPath></设置>

一个nuget包用于创建包文件夹覆盖.

2.1 版更新

正如 Azat 评论的那样,现在有关于如何控制包位置的官方文档.2.1 的 发行说明 在 nuget.config 文件中指定以下配置(有关放置配置文件的有效位置以及分层配置模型如何工作的说明,请参阅发行说明):

<预><代码><配置><配置><add key="repositoryPath" value="C: hePathToMyPackagesFolder"/></config>...</配置>

这将更改您放置文件的配置级别的包文件夹(解决方案,如果您将其放置在解决方案目录中,项目放置在项目目录中等等).请注意,发行说明指出:

<块引用>

[...] 如果您的解决方案下有一个现有的包文件夹root,您需要在 NuGet 将包放入之前将其删除新位置.

I have the following convention for most of my projects:

/src
    /Solution.sln
    /SolutionFolder
        /Project1
        /Project2
        /etc..
/lib
    /Moq
        moq.dll
        license.txt
    /Yui-Compressor
        yui.compressor.dll
/tools
    /ILMerge
        ilmerge.exe

You'll notice that I do not keep external libraries inside the source folder. I'm also very interested in using NuGet but don't want these external libraries inside the source folder. Does NuGet have a setting to change the directory that all packages are loaded into?

解决方案

It's now possible to control which folder the packages are installed into.

http://nuget.codeplex.com/workitem/215

Edit: See Phil Haack's comment on Dec 10 2010 at 11:45 PM (in the work item/the link above). The support is partially implemented in 1.0, but is not documented.

According to @dfowler: Add a nuget.config file next to the solution with this:

<settings>
<repositoryPath>{some path here}</repositoryPath>
</settings>

There is a nuget package for creating the package folder override.

Update for version 2.1

As Azat commented, there is now official documentation on how to control the package locations. The release notes for 2.1 specifies the following configuration in a nuget.config file (see the release notes for a description of valid places to put the config files and how the hierarchical configuration model works):

<configuration>
  <config>
    <add key="repositoryPath" value="C:	hePathToMyPackagesFolder" />
  </config>
  ... 
</configuration>

This would change the packages folder for the configuration level you put the file in (solution if you put it in the solution directory, project in project directory and so on). Note that the release notes state:

[...] if you have an existing packages folder underneath your solution root, you will need to delete it before NuGet will place packages in the new location.

这篇关于是否可以更改 NuGet 包的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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