1
votes

I converted a .NET Framework 4.7.2 project from packages.config to PackageReferences format by right clicking the packages.config file within VS 2019.

Since then Visual Studio shows blue icons of a NuGet package which I uninstalled from the project in the References node. What is truly weird is that without this package the build should fail as it is used within the code, but the build succeeds!

  1. There are no packagereference to this NuGet package in the .csproj file.
  2. There is no packages.config file in the project directory
  3. I deleted the .vs folder and the older packages folder
  4. Restarted Visual Studio
  5. Problem Remains
  6. uninstall-package command fired within Visual Studio says the package is not installed.
  7. Yet the Reference (Blue Icon) is shown and the project builds!

Question

  1. How do I completely remove this package from the project?
  2. How do I stop Visual Studio from referencing this package for now?
1
Would help if you could provide a screenshot for some additional context. You might also want to try nuking the package directory from %userprofile%\.nuget\packages\, then restarting VS.Ian Kemp
Just delete the reference in Solution Explorer. The reference is still in the csproj file but no longer user and is blue because the dll is not found.jdweng
Hi Ian the nuget package was also refernced in another project which was added to the original project as a Project Reference. Once I removed that project reference, the nuget package also disappeared! @jdweng - You cannot delete reference in Solution Explorer for a Nuget Package in the new world. Besides the package was not listed in the csproj file which was the source of the main confusion.Nikhil

1 Answers

0
votes

===============================

If your project does not reference any other projects or just reference a project which does not install the same nuget package, I think the issue is related to your project itself or VS environment.

And in this situation, it is quite strange that the blue icon of the nuget package still stays on the solution explorer while you have already uninstalled the nuget package.

Please try the following suggestions:

1) disable any third party extensions under Extensions-->Manage Extensions-->Installed

2) clean nuget caches and reset vs settings under Tools-->Import and Export settings-->Reset all settings

3) then close VS, delete cache files under

C:\Users\xxx(current user)\AppData\Local\Microsoft\VisualStudio\16.0_xxx\ComponentModelCache

and also delete .vs hidden folder, bin and obj folder.

4) then restart VS to test whether the issue persists.

Besides, you could use devenv /safemode to start a clean and initial VS and then test your project.

=================================

If your situation is this one:

Your project B has referenced a project called Project A while A has also installed the same nuget package. And project A uses PackageReference nuget management format.

Although you have uninstall the nuget package on Project B, your obj folder still has files like project.assert.json,xxx.nuget.g.props which is a feature of PackageReference. Due to it, the nuget package management format of Project B is the same as the Project A and will transmit the dll from the Project A into Project B so that you can use the dll in the project B.

And that delete .vs hidden folder will remove the nuget package format PackageReference of Project B since you already uninstall all the nuget packages on Project B but the PackageReference content of obj folder still exist.

So you should close VS, delete .vs hidden folder, bin and obj folder of the Project B at the same time.

Note: Rebuild and Clean will not delete the previous restore files.

If this does not work, I think you have written this xml node under B.csproj file:

<PropertyGroup>
    <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>  

So you should check in your project B carefully and it will still restore the files project.assert.json,xxx.nuget.g.props,.... as PackageReference.

Therefore, if you have, delete this node, also delete .vs hidden folder, bin and obj folder.