Switch back to packages.config - clarification on answer

一曲冷凌霜 提交于 2019-12-24 00:36:35

问题


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?


回答1:


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.




回答2:


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

Yes, you have to install those packages again. That because automatically migrating projects from PackageReference -> packages.config is not something that will be supported.

Check the thread:

https://github.com/NuGet/Home/issues/4973

To accomplish this, you can follow below steps:

First, change the Package Management to Packages.config, Tools->Options->NuGet Package Manager->Package Management:

Second, unload the project and edit it, remove all PackageReference elements out of the project file (Make sure that is not set in the project file.).

Third, reload the project, then reinstall those packages.

Hope this helps.



来源:https://stackoverflow.com/questions/53335453/switch-back-to-packages-config-clarification-on-answer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!