5
Vote

NuGet unexpected install logic

description

NuGet version 1.5.20905.5 seems to have some behavior reversed regarding when it downloads.
  • For a package which exists in a non-versioned folder, NuGet uninstalls and reinstalls the package if the -Version switch is excluded and the -ExcludeVersion switch is included.
  • For a package which exists in a non-versioned folder, NuGet does not install the package if the -ExcludeVersion switch is not excluded.
Examples:

Package already exists:

ls lib/NHibernateProfiler
NHibernateProfiler.nupkg content lib tools

Running nuget install does not download package to version folder because non-version folder exists

nuget Install NHibernateProfiler -o lib
Attempting to resolve dependency 'WebActivator (▒ 1.4)'.
Attempting to resolve dependency 'Microsoft.Web.Infrastructure (▒ 1.0.0.0)'.
'NHibernateProfiler 1.0.0.917' already installed.

Running nuget install with the -ExcludeVersion switch uninstalls and reinstalls

nuget Install NHibernateProfiler -o lib -ExcludeVersion
Successfully uninstalled 'NHibernateProfiler 1.0.0.917'.
Successfully uninstalled 'WebActivator 1.4.4'.
Successfully uninstalled 'Microsoft.Web.Infrastructure 1.0.0.0'.
Attempting to resolve dependency 'WebActivator (▒ 1.4)'.
Attempting to resolve dependency 'Microsoft.Web.Infrastructure (▒ 1.0.0.0)'.
Successfully installed 'Microsoft.Web.Infrastructure 1.0.0.0'.
Successfully installed 'WebActivator 1.4.4'.
Successfully installed 'NHibernateProfiler 1.0.0.917'.

comments

aldion wrote Oct 10, 2011 at 9:13 PM

Ill have a look.

aldion wrote Oct 13, 2011 at 10:19 PM

Right I repro with latest (1.6) nuget.exe :

C:\Users\aldion\Documents\Visual Studio 2010\Projects\WebApplication93>nuget install NhibernateProfi
ler -o lib
Attempting to resolve dependency 'WebActivator (≥ 1.4)'.
Attempting to resolve dependency 'Microsoft.Web.Infrastructure (≥ 1.0.0.0)'.
'NHibernateProfiler 1.0.0.917' already installed.

C:\Users\aldion\Documents\Visual Studio 2010\Projects\WebApplication93>nuget install NhibernateProfi
ler -o lib2 -excludeVersion
Successfully uninstalled 'NHibernateProfiler 1.0.0.917'.
Successfully uninstalled 'WebActivator 1.4.4'.
Successfully uninstalled 'Microsoft.Web.Infrastructure 1.0.0.0'.
Attempting to resolve dependency 'WebActivator (≥ 1.4)'.
Attempting to resolve dependency 'Microsoft.Web.Infrastructure (≥ 1.0.0.0)'.
Successfully installed 'Microsoft.Web.Infrastructure 1.0.0.0'.
Successfully installed 'WebActivator 1.4.4'.
Successfully installed 'NHibernateProfiler 1.0.0.917'.

JeffHandley wrote Jan 13, 2012 at 12:13 AM

It sounds like the end result is the same either way, but that extra work is performed by NuGet. Was it expected that in either case, the package would be left installed as-is without uninstalling/reinstalling?

If that's all this is, it seems rather low-priority. Is there a scenario where this leads to issues?

derekgreer wrote Feb 7, 2012 at 7:50 PM

The end result is a build which can take orders of magnitude longer than if NuGet didn't reinstall the packages.

peter172sp wrote Apr 26, 2012 at 3:28 PM

It is worth noting that this problem only occurs if you don't specify the version of the package to install.
If the build is using package restore, the nuget install command will use the packages.config which provides package versions.

Problem occurs when version is not specified:

PM> ...nuget\nuget.exe install RhinoMocks -o ........\packages\ -ExcludeVersion
Successfully uninstalled 'RhinoMocks 3.6.1'.
Successfully installed 'RhinoMocks 3.6.1'.

Package is not reinstalled if version is specified:

PM> ...nuget\nuget.exe install RhinoMocks -Version 3.6.1 -o ........\packages\ -ExcludeVersion
Package "RhinoMocks" is already installed.

Package is not reinstalled when using packages.config:

PM> ...nuget\nuget.exe install packages.config -o ........\packages\ -ExcludeVersion
All packages listed in packages.config are already installed.