Let's see how we can fix the problem explained here. According to the latest release notes, by now you should be able to change the packages folder by adding this setting in the Nuget.config file:
<configuration>
<config>
<add key="repositoryPath" value="C:\myteam\teampackages"></add>
</config>
...
</configuration>
Unfortunately, I couldn't make this work, so I found a workaround. I want to make the Second.sln use the package folder of First.sln. So I have made the following changes to the NuGet.targets file.
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
<PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir),
"packages.config"))</PackagesConfig>
</PropertyGroup>
I have added the following row:
<PackagesDir>$(SolutionDir)..\First\packages</PackagesDir>
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source
"$(PackageSources)" $(RequireConsentSwitch) -solutionDir "$(SolutionDir)</RestoreCommand>
to:
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source
"$(PackageSources)" -o "$(PackagesDir)" $(RequireConsentSwitch)
-solutionDir "$(SolutionDir)</RestoreCommand>
I have added -o "$(PackagesDir)" which should make the packages to be downloaded to the PackagesDir folder.
<PackagesDir Condition="'$(PackagesDir)'
== ''">$(SolutionDir)..\First\packages</PackagesDir>
This will allow us to predefine the PackagesDir value in the .csproj.user files.
="1.0"="utf-8"
<Project ToolsVersion="4.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PackagesDir>C:\NugetConfig\packages</PackagesDir>
</PropertyGroup>
</Project>
This will make the Nuget to get files in the C:\NugetConfig\packages folder.
- In this section:
- Change the arguments of the
NewGetCommand
from: - To make the configuration more flexible, we can change the PackagesDir definition to:
- To test this, we can add the C:\ NugetConfig\First\Dummy\Dummy.csproj.user with the following content:
And the code can be found here.