How to install NuGet packages in web projects using powershell RRS feed

  • Question

  • Hi

    Currently I am writing the testing automation to create the ASP.NET MVC web projects and ensure our controls to reduce the manual testing. For this I am using the below code for NuGet installation when create the project outside the Visual Studio. But I have faced the exception like below, 


    _nugetService = new ServiceProvider(dte as Microsoft.VisualStudio.OLE.Interop.IServiceProvider);
    var componentModel = (IComponentModel)_nugetService.GetService(typeof(SComponentModel));
    var installer = componentModel.GetService<IVsPackageInstaller>();
    installer.InstallPackage(PackagesLocation, Project, nupkg, version, false);


    Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.VisualStudio.ComponentModelHost.IComponentModel'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{605AF649-8844-3F09-9982-1258074BE833}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))

    But the above code is working fine when run the Visual Studio experimental instance from Extension project. 

    Could you please suggest the solution for resolve this issue when run the above code from outside the Visual Studio

    So, I have move to another solution like install the NuGet packages using powershell

    But I have faced the below issue, 

    Could you please suggest the solution for this?


    Ganesan R.

    Tuesday, June 25, 2019 9:05 AM

All replies