Is it possible to switch back to packages.config
scheme of things? I moved to PackageReference
scheme when I created the project, but for some reas
How I made it work:
packages.config
file to the project and copy this into it:<?xml version="1.0" encoding="utf-8"?> <packages> </packages>
Unload the project and open the csproj file in a text editor.
Remove all PackageReference elements out of the project file.
Make sure that <RestoreProjectStyle>
is not set in the project file.
Make sure that:
Tools >
Options>
NuGet Package Manager >
General>
Default package management format is set to Packages.config
Delete the obj
folder in the project
Use the screenshot to re-download the packages again
Wanted to add one more thing. I tried all above steps and Visual Studio kept trying to use the global-packages location, instead of repositoryPath from Nuget.config. Finally found that there was a package-lock.json file in the obj dir of my projects that had the global package dir stored in it. For some reason the Clean operation, in Visual Studio, didn't delete the file, so I wound up doing a
git clean -x -d -f
At the root of my repository. Which deletes all un-tracked files and directores, and ignores the patterns the .gitignore file. It was a bit excessive, I could have tried to find them all by hand, but it got the job done. Now Nuget restore properly uses the repositoryPath setting specified in the Nuget.Config file.
You'll need to:
packages.config
file to the project (that is, xml as in the example but without individual <package>
elements)csproj
file in a text editor.PackageReference
elements out of the project file.<RestoreProjectStyle>
is not set in the project file.There was one step missing for me:
4.5. Make sure that
Tools>Options>NuGet Package Manager>General>Default package management format
is set toPackages.config