Reputation: 34499
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
Upvotes: 4
Views: 898
Reputation: 34499
After about an hour, I found out what the problem was. My .NET Core library referenced Microsoft.NETCore.App
, which referenced System.Collections.Immutable
. I looked at the dependencies for the former, but overlooked System.Collections.Immutable
because that package references maybe 50 other packages. I ended up finding this out by creating a brand-new xUnit test project, and trying to see if ImmutableArray<>
was present without installing anything. Sure enough, I could use it out of the box.
Upvotes: 3
Reputation: 21
I had a similar issue with VS2017 and a different nuget package that wouldn't fully uninstall. I ultimately had to create a new project and cut and paste all my code into it. Kind of a sledge hammer approach, but faster than crawling through dependencies.
Upvotes: 0