0

I´ve loaded an old project. It has a NuGet package referenced to a version (version 1) that doesn´t exists anymore in the nuget.org remote repository. It doesn´t exists neither in my local computer. In the remote repository exists with version 2.

When I open the Nuget Package Manager this package appears in the list to be Updated (from version 1 to version 2). I do so, but it fails because it tries to find the previous version, so:

Unable to find version 1.00 of package MyPackage

If I try to Uninstall it, even checking the options:

 - Remove dependencies
 - Force uninstall

The error is the same...

Only when I modify packages.json version manually it works.

As Nuget Package Manager already knows that there is a v2 and it fails finding anywhere v1, my question is: There is not an automated way to make this work?

3
  • Since VS will execute the default restore operation automatically when you do some changes to nuget packages? So far, there is no such function to skip restore to uninstall package, you need to delete the manually delete the non-existing package in the xxx.proj file. Otherwise, you should suggest a feature to the VS Team as I provided. Commented May 28, 2020 at 9:56
  • 1
    If my answer help you handle and understand this issue, you could consider accepting it. If not, please feel free to let us know. It is kind of you to do that. All of these will help us create a good community environment. Commented Jun 3, 2020 at 3:33
  • @PerryQian-MSFT Sorry for the late reply, I didn't have the opportunity to review this before. Thanks! Commented Jun 8, 2020 at 8:20

1 Answer 1

1

As Nuget Package Manager already knows that there is a v2 and it fails finding anywhere v1, my question is: There is not an automated way to make this work?

In fact, there is no such automatic function to uninstall a non-existent nuget package by VS IDE. You should manually delete the nuget xml elements.

And when you uninstall or update a package, VS IDE will check whether the current version of nuget exists on the current machine or in the nuget package source. That is, VS IDE will do a restore extra operation when you uninstall or update the nuget package. That is the default operation.

For an example, when I uninstall a package that is not exists under local cache and package source, the error will occur:

enter image description here

And it will suggest that we should do a restore.

---------------

If you want to update or uninstall a package that does not exist, you have to delete the contents of the package manually and you have no choice:

1) delete the package content in packages.config file(if you use packages.config nuget management format) like this:

<package id="Microsoft.Data.OData" version="5.8.4" targetFramework="net462" />

2) delete like these node in xxx.csproj file:

 <Reference Include="Microsoft.Data.OData, Version=5.8.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.Data.OData.5.8.4\lib\net40\Microsoft.Data.OData.dll</HintPath>
    </Reference>

3) then install the new version of the package.

However, I think VS should take this issue seriously, and I am interested in your opinion. This seems like a bug in your current situation, and the restore operation is redundant. Therefore, when uninstalling a package, you should not have to check whether the package exists. Just uninstall or install what you want.

So I suggest you could suggest this feature on our User Voice Forum and the Team will seriously consider your idea and give you a satisfactory feedback.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.