I've got a class library that till today was for .NET 4.5, now I've been asked to port it to .NET 40 but I've got some difficulies. I've followed this approach
and it works for the nuget packages that
but using this approach I get an error when going to Manage Nuget Packages telling
What's the most clean way to target different .NET framework version without loosing nuget package manager?
The error message caused by the duplicate packages listed in packages.config file. Because the Manager NuGet Packages window will read the packages.config file to list installed packages in your project and manage them.
For your situation, please check whether the packages in your project could compatible with both of .NET 4.5 and .NET 4.0. If yes, you need not to use two version packages in one project. You just need to change the project .NET Framework through Project -> Properties -> Application -> Target Framework.
If the installed packages version could not compatible with .NET 4.5 and .NET 4.0 at the same time, and you still want to use the Manager NuGet Packages, I suggest you do with below manual operation: Comment out one version of the packages in packages.config file and then open Manager NuGet Packages. After using Manager NuGet Packages, please uncomment the version that commented before.