Vlad Stryapko
Vlad Stryapko

Reputation: 1057

How NuGet determines if reinstallation is required

There is a 'requireReinstallation' tag in packages.config, which purpose is pretty clear. However, I was wondering how exactly NuGet decides whether the package requires reinstallation or not. I've had a project with Serilog and RayGun packages and after upgrading the .NET version, only Serilog got the tag set. What's the algorithm behind this?

Upvotes: 1

Views: 404

Answers (1)

Matt Ward
Matt Ward

Reputation: 47967

The algorithm is the same as the algorithm that is used to determine which assembly is the best match for the project if the NuGet package was to be installed into the project if it had the new target framework. If the assembly is different then NuGet considers that a reinstallation is required.

So if you had Foo and Bar NuGet packages installed with:

  • Foo

    • lib/net45
  • Bar

    • lib/net45
    • lib/net46

And your project was targeting .NET 4.5, and you changed it to .NET 4.6, then NuGet would mark Bar as needing reinstallation. Bar has an assembly that targets .NET 4.6 so it is considered a better match. Foo would not need to be reinstalled.

Upvotes: 3

Related Questions