NuGet package refuses to uninstall in .NET Core library

Viewed 687

I'm creating a .NET Core xUnit test project library in VS2017. I accidentally installed the System.Collections.Immutable NuGet package, and now I want to uninstall it.

  • First, I tried editing the csproj file and removing this line:

    <PackageReference Include="System.Collections.Immutable" Version="1.3.1" />
    
  • That didn't work, since the types from that package were still highlighted in the editor. So I tried running Uninstall-Package System.Collections.Immutable in the Package Manager Console.

  • The console said it couldn't find the package, so I tried putting the <PackageReference... line above back and running Uninstall-Package again. The console said the uninstall succeeded, but VS still recognized the types.

  • I tried closing VS, deleting .vs/, and reopening. It still recognized the types.

  • I tried git stashing my changes, running git clean -xdf, and running dotnet restore from the command line. Somehow, it still outputs

    $ dotnet restore
    Restoring packages for C:\cygwin64\home\james\Code\cs\BlockList\src\BlockList\BlockList.csproj...
    Restoring packages for C:\cygwin64\home\james\Code\cs\BlockList\src\BlockList.Tests\BlockList.Tests.csproj...
    ...
    Installing System.Collections.Immutable 1.2.0.
    Installing System.Collections.Immutable 1.3.0.
    ...
    
  • I also tried restoring from Visual Studio instead of the command line. Still no luck.

When I searched all the files in my repo for the word Immutable, the only thing popping up is project.assets.json in the obj directory. Not a single source file contains the word Immutable. I'm confused, then, as to how it's still being referenced. How can I uninstall it?

A few other things:

  • I checked the 'Dependencies' drop-down for my project in Solution Explorer, and it's not listed there.

  • I don't want to delete my local copy of the repo and re-clone it, since I have other work stashed.

  • System.Collections.Immutable.dll doesn't show up at all in the bin/ directory, yet when I use one of the types in my library and run it, it works fine.

Thanks!

edit: Adding this line to the library:

System.Diagnostics.Debug.WriteLine(typeof(ImmutableArrayExtensions).GetTypeInfo().Assembly.Location);

And running it says that the assembly is located in this location:

C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Collections.Immutable.dll
2 Answers
Related