The solution proposed in release notes for 2.1 doesn t work out-of-the-box. They forgot to mention that there is code:
internal string ResolveInstallPath()
{
if (!string.IsNullOrEmpty(this.OutputDirectory))
{
return this.OutputDirectory;
}
ISettings settings = this._configSettings;
...
}
which prevents it from working. To fix this you need to modify your NuGet.targets file and remove OutputDirectory parameter:
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(RequireConsentSwitch)</RestoreCommand>
So now, if you add repositoryPath config somewhere in NuGet.config (see the release notes for a description of valid places to put the config files), it will restore all packages into single location, but... Your .csproj still contains hints to assemblies written as relative paths...
I still don t understand why they went hard way instead of changing PackageManager so it would add hint paths relative to PackagesDir. That s the way I do manually to have different package locations locally (on my desktop) and on build agent.
<Reference Include="Autofac.Configuration, Version=2.6.3.862, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>$(PackagesDir)Autofac.2.6.3.862libNET40Autofac.Configuration.dll</HintPath>
</Reference>