MissingMethodException NuGet.VisualStudio.IVsPackageInstaller.InstallPackage

Topics: General
Dec 2, 2013 at 12:46 PM
Hello I have built a Visual Studio Extension and it is working nicely, however some people are reporting an error with a MissingMethodException with the .visx extension

The exception they are getting is as follows:
System.MissingMethodException: Error: Missing method 'instance void [Umbraco.VS.NewProject.Wizard.WPF] NuGet.VisualStudio.IVsPackageInstaller::InstallPackage(class [NuGet.Core]NuGet.IPackageRepository,class EnvDTE.Project,string,string,bool,bool)' from class 'NuGet.VisualStudio.VsPackageInstaller'.

   at NuGet.VisualStudio.IVsPackageInstaller.InstallPackage(IPackageRepository repository, Project project, String packageId, String version, Boolean ignoreDependencies, Boolean skipAssemblyReferences)

   at Umbraco.VS.NewProject.Wizard.WPF.Wizard.GetUmbraco(Project project, String umbracoNugetVersion)

   at Umbraco.VS.NewProject.Wizard.WPF.Wizard.ProjectFinishedGenerating(Project project)
So from what I understand the problem is that this method cannot be called for whatever reason: NuGet.VisualStudio.IVsPackageInstaller.InstallPackage

Here is the source file from my project on GitHub that is calling InstallPackage() from Nuget.VisualStudio

https://github.com/warrenbuckley/Umbraco-VS-New-Project/blob/master/Umbraco.VS.NewProject/Umbraco.VS.NewProject.Wizard.WPF/Wizard.cs#L230

Would anyone have any pointers or ideas why this might be the case please?

Many Thanks,
Warren
May 22, 2014 at 5:50 PM
I also have this error when trying to Install Nuget Packages from IVsPackageInstaller with a PackageRepository.
It is working fine without PackageRepository by directly specifying the source (string).

Does anyone has a workaround?

Thanks,
Steven
Mar 9, 2015 at 7:13 AM
It seems to be caused by that there is another version of NuGet installation in target machine other than the project referred.

Changing to refer the current version NuGet installed in target machine will resolve the issue. Good Luck!