The following code is raising NullReferenceException ("Object reference not set to an instance of an object.") on Visual Studio 2015, NuGet.VisualStudio v3.3).
try { this.PackageInstaller.InstallPackage(packageSource, project, packageId, version, ignoreDependencies); } catch (Exception ex) { string error = string.Format(CultureInfo.CurrentCulture, Properties.Resources.RES_Error_InstallingNuGetPackage, packageId, project.Name); throw new NuGetServiceException(error, ex); } The PackageInstaller is an instance of NuGet.VisualStudio.IVsPackageInstaller.
The problem seems to have something to do with the values of version, and may be packageSource.
When this error is raised the values are:
packageSource = "All" version = null If I change the value of version to the latest available version of the package ("3.00.00.1041") then the exception is InvalidOperationException ("Unable to find version '3.00.00.1041' of package 'Primavera.Core.Patterns.Models'.").
This does not make any sense because this works perfectly in the Package Manager Console and it installs exactly that version. It seems to be a bug in the NuGet.VisualStudio code base.
Any ideas?