.net 如何指定安装 NuGet 包的目录?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7676640/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I specify the directory where NuGet packages are installed?
提问by Diego Dias
How to do to specify the directory where I want install package? Because I need install packages in a project where others devs work and when they do download of the project they need have all packages in your pc.
如何指定我要安装包的目录?因为我需要在其他开发人员工作的项目中安装软件包,并且当他们下载该项目时,他们需要在您的电脑中安装所有软件包。
采纳答案by Geri Borbás
回答by Danny Tuppeny
The packages go in $(SolutionDir)\packages. You have two options:
包在 $(SolutionDir)\packages 中。您有两个选择:
- Check the packages folder into source control
- Use NuGetPowerToolsso that developer machines will automatically fetch the packages when you build
- Type "Install-Package NuGetPowerTools" in the Package Manager Console
- Type "Enable-PackageRestore" in the Package Manager Console
- This adds a $(SolutionDir).nuget folder, which contains an MSBuild target that will fetch the packages when they're required (eg. if you build on a machine that doesn't already have them). You must check the .nuget folder, and associated csproj changes into source control!!
- 将包文件夹检查到源代码管理中
- 使用NuGetPowerTools以便开发人员机器在您构建时自动获取包
- 在包管理器控制台中键入“Install-Package NuGetPowerTools”
- 在包管理器控制台中键入“Enable-PackageRestore”
- 这会添加一个 $(SolutionDir).nuget 文件夹,其中包含一个 MSBuild 目标,该目标将在需要时获取包(例如,如果您在没有它们的机器上构建)。您必须检查 .nuget 文件夹,并将关联的 csproj 更改为源代码管理!!
I'd recommend notchecking the packages folder in, since binary files in DVCS make for slow clones :-( In the next version of NuGet, you won't need NuGetPowerTools to avoid checking it in :-)
我建议不要签入包文件夹,因为 DVCS 中的二进制文件会导致慢速克隆 :-( 在下一版本的 NuGet 中,您将不需要 NuGetPowerTools 来避免签入 :-)
回答by Grinn
You can now change the default $(SolutionDir)\packagesfolder. See this thread: Is it possible to change the location of packages for NuGet?
您现在可以更改默认$(SolutionDir)\packages文件夹。请参阅此线程:是否可以更改 NuGet 包的位置?

