Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget re-targeting after upgrading from .Net Framework 4.5 to 4.6.1 [duplicate]

People also ask

How do I reinstall NuGet package?

Switch to the Browse tab, search for the package name, select it, then select Install). For all packages, delete the package folder, then run nuget install . For a single package, delete the package folder and use nuget install <id> to reinstall the same one.

How do I update NuGet with latest version?

Right-click the Packages folder in the project, and select Update. This will update the NuGet package to the latest version. You can double-click the Add packages and choose the specific version.

What is package config Targetframework?

packages. config: The targetframework attribute of a dependency specifies the variant of a package to install.


The packages will not be retargeted automatically, but there is an automated fix for this.

In Package Manager Console simply run:

Update-Package -Reinstall

This will force the package manager to reinstall every package in every project (without changing the version of the referenced package).

By reinstalling the packages after the new framework is targeted this changes all the references to the correct version.

You may also run this against a single project with :

Update-Package -Reinstall -ProjectName Project.Name.Here

I have used this technique many times to fix nuget reference issues.


1 Find all .csproj files and replace

<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>

with

<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>

2 Open Package Manager Console and run

Update-Package -Reinstall -IgnoreDependencies

3 Find all solutions then msbuild each one.


Fixed by using -

Update-Package -reinstall

enter image description here