NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 252 forks source link

Cannot update a package if it hasn't been restored #2344

Closed PhilipDaniels closed 8 years ago

PhilipDaniels commented 8 years ago

Scenario

I have created a library LIB that uses a package which is at version 1.1 (say). I was doing this on ComputerA, which had LIB1.1 available on a local nuget package directory (so it's not in the cloud).

I then clone the project on ComputerB, which doesn't have LIB1.1 available. However, it does have LIB1.2 available.

The Updates tab shows LIB as available for update (which is correct)

Problem When you press the UPDATE button you get an error "NuGet Package restore failed for project X, unable to find version 1.1 of LIB".

Expected behaviour The update should succeed. I am trying to install the latest version (1.2), so it shouldn't first try to restore the old version, which is not available.

Edit Actually, the situation is even worse, because I can't even uninstall LIB 1.1 using the UI - that tries to do a restore too! So now the only option is to manually edit the packages.config file.

PhilipDaniels commented 8 years ago

Just browing through the issue list...probably a duplicate of #2213

yishaigalatzer commented 8 years ago

Yes it is, thank you!

The issue here is that the code doesn't know what the content of the package is, so when you say update the code cannot safely do that.

The following scenarios are going to be broken (and I understand you might not fall in this scenario)

  1. The package contains content files, that might change between versions. So you will be left with leftover files
  2. The package contains uninstall.ps1 - It won't run
  3. The package contains xdt transforms, same as above.

You might want to look at moving your projects to use project.json instead of packages.config, you will gain many advantages (like projects are not going to get edited when you update packages, you can update the project.json file directly and just restore). This model is not officially supported, but it does work and that is how we build NuGet, Roslyn builds Roslyn and some other major projects follow the same pattern.