visual studio – How to permanently remove an unused transitive NuGet package


NuGet

After switching from System.Data.SqlClient to Microsoft.Data.SqlClient in one of my solutions I am unable to permanently remove unused System.Data.SqlClient from the solution as it keeps getting restored by NuGet.
When I search the entire solution for ‘System.Data.SqlClient’ nothing is found and none of the .csproj files contain a PackageReference entry for it.

What I tried so far:

  • Clean/Rebuild solution.
  • Delete all the bin/obj folders under affected projects followed by Clean/Rebuild solution.
  • nuget locals all -clear followed by Clean/Rebuild.
  • nuget delete System.Data.SqlClient 4.8.1 in Package Manager Console
  • Install the latest as Top-level package and uninstall (when I do this 4.8.1 is again restored as Transitive.

I have no further ideas.

Leave a Reply

Your email address will not be published. Required fields are marked *