How can I go back to referencing Nuget packages in .config packages after using package referencing in a .NET Standard project?
Background
I have several C # code libraries that I recently converted to target .NET Standard 1.4 for use in a Xamarin Forms project as well as many older .NET Framework 4.6.1 projects.
First, I added Nuget packages to the .NET Standard Class Libraries using the Package Reference in Project Files .
After investigating this error where links to transitional packages from .NET Standard projects are not allowed in older .NET Framework projects , I tried a workaround to add <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
csproj to the legacy project. Legacy projects continued not to resolve transient references, i.e. The workaround didn't help.
So, I would like to revert to the old style of referencing Nuget packages in the packages.config file in my .NET Standard project.
Sequence of steps:
- Removing all Nuget packages in a .NET Standard project except NETStandard.Library which cannot be removed
- My VS default setup for Nuget is to add the first package to the solution package.config
- Reinstalling Nuget Package from Tool Window
Manage Nuget Packages
- This package is placed in csproj as
PackageReference
, not in package.config file.
- This package is placed in csproj as
Does anyone know how I can get the new Nuget packages in my .NET Standard 1.4 project to be listed in packages.config
instead of package references?
source to share
How to rollback to packages.config
-
Close the migrated project.
-
Copy the project file and packages.config from the backup (usually \ MigrationBackup \\) to your project folder. Delete the obj folder if it exists in the project root.
-
Open your project.
-
Open the Package Manager Console by using the Tools> NuGet Package Manager> Package Manager Console menu command.
-
Run the following command in the console:
update package -reinstall
source to share
- remove all PackageReference in the project file.
- deleting all caches in $ ProjectDir \ obj.
- add an empty packages.config file (with root tags) to the project.
- rebuild the project. Then Visual Studio will tell you what is missing.
- Then add the package of the selected version using the Nuget Manager.
- Repeat steps 4 and 5, VS will add your link one by one back to the packages.config file.
source to share