Search code examples
visual-studio-2017nugetpackagereferencepackages.config

Switch back to packages.config - clarification on answer


In line with the rules, I have to ask a new question, to get some clarification on another question/answer.

This answer is this one: https://stackoverflow.com/a/45964469/305916

Then what? Just did the accepted answer, but the packages.config file is not populated with the packages (I know it doesn't say so).

I am missing what to do next if the packages appear automatically in the packages.config or I need to install them again...

I am leaning towards the latter, but I feel the answer is not complete :)

But what to do?


Solution

  • Firstly, do you mind editing your question, or posting as a comment, why you want to revert back to packages.config? As a member of the NuGet team, it's useful to know the reasons why PackageReference doesn't work for you. If it's not one of the reasons listed in as a limitations of PackagesConfig, including the package compatibility section, perhaps we can help resolve that issue so you can keep using PackageReference.

    If you really want to revert to packages.config, I suggest the following, not the answer that you linked.

    1. Go to Options, NuGet PackageManager->General and enable Allow format selection on first package install
    2. Uninstall all packages in your project using "Manage NuGet Packages" (Package Manager UI). You can use Package Manager Console to uninstall, but you must use Package Manager UI for the next step. Keep track of which packages you uninstall, so you know which to install again in the next step.
    3. Once your project has no package references, then install the packages you need again. The first package you install will pop up a dialog where you choose to use packages.config or PackageReference. If you didn't keep track of which packages you uninstalled in the previous step, use your source control system to diff your project file, or look at an unmodified copy, and look for all instances of PackageReference.

    It's necessary to uninstall all packages in the project installing a new one, because if any PackageReference exists in the project file, NuGet will add new packages as PackageReference. Therefore you can't uninstall the first package, re-install it, then move the second package in the project.