I want to specify where the packages are stored on a nuget restore. Of course, this is documented on MSDN, and of course, it never works....
I have a test solution stored in D:\Development\Test\Test.sln
According to their documentation, nuget no longer looks in the .nuget folder inside the solution folder. Instead it now looks in the solution folder, or further up the chain. So I could store a nuget.config in
- D:\Development\Test\Nuget.Config
- D:\Development\Nuget.Config
- D:\Nuget.Config
Well, I tried all three of them, and restarted Visual studio more times than I am willing to count.
I also read, that they did such a crappy job implementing nuget, that typos inside the nuget.config result in silently ignoring the nuget file. So I thought, that must be it, I made a typo. So I downloaded nuget.exe (latest stable 5.0.2) and issued the commands to configure nuget to put my packages location where I want it.
nuget config -set repositoryPath=D:\Development\test\packages -configfile ..\nuget.config
This is how the XML looks like:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="D:\Development\test\packages" />
</config>
</configuration>
After configuring Nuget.config using nuget.exe, I again tried any of the previous locations (D:\;D:\Development\;D:Development\Test), restarted visual studio every change of location, richt click solution, choose 'restore nuget packages', and the same result: zero packages are restored to my designated repository path.
So as a last attempt, I tried to nuget restore from the command line:
D:\Development\test>nuget restore test.sln -ConfigFile ..\nuget.config
MSBuild auto-detection: using msbuild version '16.1.76.45076' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\bin'.
Restoring packages for D:\Development\test\test\test.csproj...
Restoring packages for D:\Development\test\ClassLibrary1\ClassLibrary1.csproj...
Committing restore...
Committing restore...
Generating MSBuild file D:\Development\test\ClassLibrary1\obj\ClassLibrary1.csproj.nuget.g.props.
Generating MSBuild file D:\Development\test\test\obj\test.csproj.nuget.g.props.
Writing assets file to disk. Path: D:\Development\test\ClassLibrary1\obj\project.assets.json
Writing assets file to disk. Path: D:\Development\test\test\obj\project.assets.json
Restore completed in 603,63 ms for D:\Development\test\ClassLibrary1\ClassLibrary1.csproj.
Restore completed in 603,6 ms for D:\Development\test\test\test.csproj.
NuGet Config files used:
D:\Development\nuget.config
It even mentions that it uses my nuget.config, but again, ZERO packages restored in my designated package folder!
I really hope that anybody can tell me in what mysterious way this is supposed to work.