Reputation: 35460
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 reasons need to move to old way of things now.
I have tried Package Manager Console commands like restore with Update
and Reinstall
options. They do not generate packages.config anymore. I also switched Tools > Options > NuGet Package Manager
to packages.config
. No good.
Upvotes: 28
Views: 14058
Reputation: 549
I did this and was doing some nuget bundling and noticed that my dependencies were not coming over and decided to rollback and found this helpful article from Microsoft:
How to roll back to packages.config
Close the migrated project.
Copy the project file and packages.config from the backup (typically <solution_root>\MigrationBackup<unique_guid><project_name>) to the project folder. Delete the obj folder if it exists in the project root directory.
Open the project.
Open the Package Manager Console using the Tools > NuGet Package Manager > Package Manager Console menu command.
Run the following command in the Console:
update-package -reinstall
This is actually saving me right now and I wanted to post this just in case others had a similar problem.
Upvotes: 0
Reputation: 374
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
Upvotes: 2
Reputation: 100791
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.Upvotes: 49
Reputation: 175
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.
Upvotes: 5
Reputation: 486
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
Upvotes: 14