5

Closed

Update-Package does not work when the solution has associated nuget.config

description

Hi, in many projects I've done this setup:
/src/nuget.config
/src/App.sln
/src/Lib1/Lib1.csproj
/src/Lib2/Lib2.csproj
/lib/repositories.config
the nuget.config has the following content:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="repositoryPath" value="../lib/" />
  </config>
</configuration>
This way the packages are installed in a /lib/ directory at the same level of the /src/ directory. This work fine for package installation, but when i do a package update for a package shared on multiple projects i get an error saying the the second project does not reference the package I'm updating. This result in having only one project updated with a reference to the new package version and all other projects keeping the old version.

Seems that Update-Package does not work when changing repositoryPath location.

If I delete the /src/nuget.config file and move the /lib/ directory in the default /src/packages directory everything work fine.

file attachments

Closed Jul 22, 2013 at 7:17 PM by deepakverma
Verified the error doesn;t repro on 2.7 drop with the sample.

comments

dotnetjunky wrote May 7, 2013 at 9:51 PM

What is the exact text that you enter for the "Update-Package" command?

Gimmi wrote May 26, 2013 at 4:20 PM

Steps to reproduce

  • Download the sample project HERE
  • Run .\build.cmd Compile
  • Open .\src\Log4Mongo.sln
  • Left click on solution, Click on "Manage NuGet Package for Solution..."
  • Update "mongocsharpdriver" package (should propose to update in at least 2 projects)

Expected behavior

"mongocsharpdriver" package should be updates on all the project that reference it

Actual behavior

The first project get the update, but not the second. The error message is "Error: Log4Mongo.Tests does not reference 'mongocsharpdriver'."

RanjiniM wrote Jun 25, 2013 at 7:06 PM

@DeepakVerma, can you please try to repro this issue?

deepakverma wrote Jul 12, 2013 at 12:30 AM

Thanks for sharing the project.
Here is the output for the update. It removed 1.7 and now the test project doesn't resolve the assembly and shows this message Error: Log4Mongo.Tests does not reference 'mongocsharpdriver'."

------- Updating...mongocsharpdriver 1.8.1 -------
Installing 'mongocsharpdriver 1.8.1'.
Added file 'MongoDB.Bson.dll' to folder 'mongocsharpdriver.1.8.1\lib\net35'.
Added file 'MongoDB.Bson.XML' to folder 'mongocsharpdriver.1.8.1\lib\net35'.
Added file 'MongoDB.Driver.dll' to folder 'mongocsharpdriver.1.8.1\lib\net35'.
Added file 'MongoDB.Driver.XML' to folder 'mongocsharpdriver.1.8.1\lib\net35'.
Added file 'License.rtf' to folder 'mongocsharpdriver.1.8.1'.
Added file 'mongocsharpdriver.1.8.1.nuspec' to folder 'mongocsharpdriver.1.8.1'.
Added file 'mongocsharpdriver.1.8.1.nupkg' to folder 'mongocsharpdriver.1.8.1'.
Successfully installed 'mongocsharpdriver 1.8.1'.
'mongocsharpdriver 1.8.1' already installed.
Looking for updates for 'mongocsharpdriver'...
Updating 'mongocsharpdriver' from version '1.7' to '1.8.1' in project 'Log4Mongo'.
Removing 'mongocsharpdriver 1.7' from Log4Mongo.
Removed reference 'MongoDB.Bson.dll' from project 'Log4Mongo'
Removed reference 'MongoDB.Driver.dll' from project 'Log4Mongo'
Added file 'packages.config'.
Successfully removed 'mongocsharpdriver 1.7' from Log4Mongo.
Adding 'mongocsharpdriver 1.8.1' to Log4Mongo.
Added reference 'MongoDB.Bson' to project 'Log4Mongo'
Added reference 'MongoDB.Driver' to project 'Log4Mongo'
Added file 'packages.config'.
Successfully added 'mongocsharpdriver 1.8.1' to Log4Mongo.
Uninstalling 'mongocsharpdriver 1.7'.
Removed file 'MongoDB.Bson.dll' to folder 'C:\Users\deepakv\Downloads\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\src..\lib\mongocsharpdriver.1.7\lib\net35'.
Removed file 'MongoDB.Bson.pdb' to folder 'C:\Users\deepakv\Downloads\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\src..\lib\mongocsharpdriver.1.7\lib\net35'.
Removed file 'MongoDB.Bson.XML' to folder 'C:\Users\deepakv\Downloads\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\src..\lib\mongocsharpdriver.1.7\lib\net35'.
Removed file 'MongoDB.Driver.dll' to folder 'C:\Users\deepakv\Downloads\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\src..\lib\mongocsharpdriver.1.7\lib\net35'.
Removed file 'MongoDB.Driver.pdb' to folder 'C:\Users\deepakv\Downloads\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\src..\lib\mongocsharpdriver.1.7\lib\net35'.
Removed file 'MongoDB.Driver.XML' to folder 'C:\Users\deepakv\Downloads\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\src..\lib\mongocsharpdriver.1.7\lib\net35'.
Removed folder 'C:\Users\deepakv\Downloads\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\src../lib/mongocsharpdriver.1.7\lib\net35'.
Removed folder 'C:\Users\deepakv\Downloads\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\src../lib/mongocsharpdriver.1.7\lib'.
Removed file 'License.rtf' to folder 'C:\Users\deepakv\Downloads\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\src..\lib\mongocsharpdriver.1.7'.
Removed file 'Release Notes v1.7.txt' to folder 'C:\Users\deepakv\Downloads\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\src..\lib\mongocsharpdriver.1.7'.
Removed file 'mongocsharpdriver.1.7.nuspec' to folder 'C:\Users\deepakv\Downloads\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\src..\lib\mongocsharpdriver.1.7'.
Removed file 'mongocsharpdriver.1.7.nupkg' to folder 'C:\Users\deepakv\Downloads\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\src..\lib\mongocsharpdriver.1.7'.
Removed folder 'C:\Users\deepakv\Downloads\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\log4mongo-net-75d642ae067d3d08234ebd5b84ec6427740fde5f\src../lib/mongocsharpdriver.1.7'.

Successfully uninstalled 'mongocsharpdriver 1.7'.

Gimmi wrote Jul 12, 2013 at 6:59 AM

Thanks for taking time to reproduce it. Some questions:
  • How did you run NuGet to show all that logging?
  • Is there a way to show/log what NuGet.Config file are loaded and what is the final merged configuration is?
  • NuGet Configuration File report that "If value starts with $\ then location is relative to this conf file", but NuGet Configuration Settings does not mention this. Does this feature exists?
  • If i specify a relative path without "$\" in a nuget.config file, what is relative to?
Thanks.

dotnetjunky wrote Jul 12, 2013 at 10:48 PM

The $\ feature doesn't exist. We should remove it.

dotnetjunky wrote Jul 12, 2013 at 10:48 PM

The relative path should be relative to nuget.config file.

dotnetjunky wrote Jul 13, 2013 at 12:00 AM

The bug turns out that NuGet doesn't recognize the / slash in the repositoryPath as a valid directory separator. As a workaround for now, if you change the nuget.config to use \ slash, it will work.

<add key="repositoryPath" value="..\lib\" />

Gimmi wrote Jul 13, 2013 at 7:40 AM

Now it works, tanks!

The nasty behavior is that "/" slash are recognized almost everywhere in NuGet, but not during package update. This smell like code duplication in NuGet codebase....

Anyway, would be very useful for other nuget user to report this in the "NuGet Configuration Settings" and "NuGet Configuration File" pages previously mentioned, and remove the documentation about the inexistent "$\" feature.

dotnetjunky wrote Jul 16, 2013 at 1:21 AM

Fixed in changeset cc6760a6212f61e5f465c802e7058ebb82a8690d