简体   繁体   English

是否可以更改软件包管理器控制台的软件包安装目录?

[英]It is possible to change packages installation directory for Package Manager Console?

I'm using nuget integration with msbuild (visual studio 2012) to automatically restore broken packages. 我正在将nuget与msbuild(Visual Studio 2012)集成,以自动恢复损坏的程序包。 Below you can see my .nuget/nuget.config file for solution: 在下面,您可以查看我的.nuget / nuget.config文件以获取解决方案:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageRestore>
    <add key="enabled" value="True" />
  </packageRestore>
  <disabledPackageSources />
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
  <config>
    <add key="repositoryPath" value="..\..\Lib\NuGet\Packages" />
  </config>
</configuration>

My packages directory moved outside from solution. 我的包目录从解决方案移到了外面。 This works fine during build, but Package Manager Console still using $(SolutionDir)\\packages to install (and restore) packages. 在构建过程中,此方法工作正常,但Package Manager Console仍使用$(SolutionDir)\\packages来安装(和还原)软件包。

It is possible to change packages directory for "Package Manager Console"? 是否可以更改“ Package Manager控制台”的软件包目录?

nuget.config nuget.config

You got the first part: 您已经获得了第一部分:

  <config>
    <add key="repositoryPath" value="..\MySuperCoolPackages" />
  </config>

But you have to tell the command line about the nuget.config file explicitly. 但是您必须明确地告诉命令行有关nuget.config文件的信息。

C:\SomeFolder\NuGet.exe install "C:\MySolution\.nuget\packages.config" -ConfigFile "C:\MySolution\.nuget\nuget.config"

When you create nuget.config with repositoryPath you need to restart VS for it to be reread and console to be aware of it. 当使用repositoryPath创建nuget.config时,您需要重新启动VS以便重新读取它,并通过控制台对其进行注意。

Edit: @DmitryBykadorov weird, may be your nuget is out of date? 编辑:@DmitryBykadorov很奇怪,可能是您的nuget过时了吗? There was an early problem where due to config being in .nuget subfolder and not in .csproj 's current>parent>parent>etc path it wouldn't see it and required one nuget.config with restore info and one (typically next to .sln or .csproj itself) with repositoryPath , but my VS2012 with whatever latest nuget it comes with works fine with config below. 有一个早期的问题,由于配置位于.nuget子文件夹中,而不是位于.csproj的current> parent> parent> etc路径中,因此它将看不到它,并且需要一个带有还原信息的nuget.config和一个(通常nuget.config .sln或.csproj本身)与repositoryPath ,但是我的VS2012及其最新的nuget都可以在下面的config中正常工作。 May be your global nuget config somehow affects it, or your solution needs hard clean/rebuild? 可能是您的全局nuget配置以某种方式影响了它,或者您的解决方案需要进行严格的清理/重建?

<configuration>
  <solution>
    <add key="disableSourceControlIntegration" value="true" />
  </solution>
  <config>
    <add key="repositoryPath" value="..\..\lib" />
  </config>
</configuration>

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

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