jeudi 28 mai 2015

Programatically change NuGet options

How can we, using c#, programmatically change the NuGet Visual Studio option? The one that appears at Tools -> Options -> NuGet Package Manager -> General -> Automatically check for missing packages during build in Visual Studio.

var dte = EnvDTE.DTE;
var properties = dte.Properties["NuGetPackageManager", "General"];

The code above throws the following exception:

System.Runtime.InteropServices.COMException occurred
  HResult=-2147352565
  Message=Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
  Source=""
  ErrorCode=-2147352565

Some of my automated tests need the enablenugetpackagerestore switched off and I am trying to automate this and not switch off for all tests.

Aucun commentaire:

Enregistrer un commentaire