NuGet product used: Package Manager Console
VS version: 15.7.5
OS version: Win10 Version 1803 Build 17134.167
I get the following error message:
The following error occurred while loading the extended type data file: , C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\NUGET\Modules\NuGet\NuGet.Types.ps1xml: The file was skipped because of the following validation exception: File C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\NUGET\Modules\NuGet\NuGet.Types.ps1xml cannot be loaded because its operation is blocked by software restriction policies, such as those created by using Group Policy.
I've tried reinstalling NuGet Package Manager, reinstalling PowerShell 2.0. I even tried deleting %localappdata%\microsoft\visualstudio before running VS again. All without success.
The PowerShell execution policies are as follows:
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Unrestricted
LocalMachine RemoteSigned
What is blocking the scripts in the package manager console?
The only thing found in the Visual Studio activity log related to this issue is the following:
System.Management.Automation.CmdletInvocationException: The following error occurred while loading the extended type data file: , C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\NUGET\Modules\NuGet\NuGet.Types.ps1xml: The file was skipped because of the following validation exception: File C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\NUGET\Modules\NuGet\NuGet.Types.ps1xml cannot be loaded because its operation is blocked by software restriction policies, such as those created by using Group Policy..
 ---> System.Management.Automation.RuntimeException: The following error occurred while loading the extended type data file: , C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\NUGET\Modules\NuGet\NuGet.Types.ps1xml: The file was skipped because of the following validation exception: File C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\NUGET\Modules\NuGet\NuGet.Types.ps1xml cannot be loaded because its operation is blocked by software restriction policies, such as those created by using Group Policy..

 at System.Management.Automation.Runspaces.InitialSessionState.ThrowTypeOrFormatErrors(String resourceString, String errorMsg, String errorId)
 at System.Management.Automation.Runspaces.InitialSessionState.UpdateTypes(ExecutionContext context, Boolean updateOnly)
 at System.Management.Automation.Runspaces.InitialSessionState.Bind_UpdateTypes(ExecutionContext context, Boolean updateOnly)
 at System.Management.Automation.Runspaces.InitialSessionState.<>c__DisplayClass142_0.<Bind>b__0()
 at System.Management.Automation.Runspaces.InitialSessionState.Bind(ExecutionContext context, Boolean updateOnly, PSModuleInfo module, Boolean noClobber, Boolean local)
 at System.Management.Automation.Runspaces.InitialSessionState.Bind(ExecutionContext context, Boolean updateOnly)
 at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String moduleManifestPath, ExternalScriptInfo manifestScriptInfo, Hashtable data, Hashtable localizedData, ManifestProcessingFlags manifestProcessingFlags, Version minimumVersion, Version maximumVersion, Version requiredVersion, Nullable`1 requiredModuleGuid, ImportModuleOptions& options, Boolean& containedErrors)
 --- End of inner exception stack trace ---
 at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
 at NuGetConsole.Host.PowerShell.Implementation.RunspaceDispatcher.<>c__DisplayClass20_0.<InvokeCore>b__0()
 at NuGetConsole.Host.PowerShell.Implementation.RunspaceDispatcher.WithLock(Action act)
 at NuGetConsole.Host.PowerShell.Implementation.RunspaceDispatcher.InvokeCore(Pipeline pipeline, IEnumerable`1 inputs)
 at NuGetConsole.Host.PowerShell.Implementation.RunspaceDispatcher.Invoke(String command, Object[] inputs, Boolean outputResults)
 at NuGetConsole.Host.PowerShell.Implementation.RunspaceDispatcher.ImportModule(String modulePath)
 at NuGetConsole.Host.PowerShell.Implementation.RunspaceManager.LoadModules(RunspaceDispatcher runspace)
 at NuGetConsole.Host.PowerShell.Implementation.RunspaceManager.CreateAndSetupRunspace(IConsole console, String hostName)
 at NuGetConsole.Host.PowerShell.Implementation.RunspaceManager.<>c__DisplayClass2_0.<GetRunspace>b__0(String name)
 at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
 at NuGetConsole.Host.PowerShell.Implementation.RunspaceManager.GetRunspace(IConsole console, String hostName)
 at NuGetConsole.Host.PowerShell.Implementation.PowerShellHost.<>c__DisplayClass69_0.<<Initialize>b__0>d.MoveNext()
Any help would be very much appreciated.
I have found that somehow 3 certificates issued by Microsoft Corporation ended up in the list of Untrusted Publishers on my machine (Internet Options | Content | Certificates).
After removing them from that list, the package manager console started working again (along with some other things that were behaving strangely in Visual Studio).
Thank you Sir this is really helpful
Most helpful comment
I have found that somehow 3 certificates issued by Microsoft Corporation ended up in the list of Untrusted Publishers on my machine (Internet Options | Content | Certificates).
After removing them from that list, the package manager console started working again (along with some other things that were behaving strangely in Visual Studio).