0

I updated to Visual Studio 2013.5 and installed Visual Studio 2015 yesterday. Since the installation of the updates, NuGet doesn't work anymore in both Visual Studio versions.

The error I get is:

Set-ExecutionPolicy : Windows PowerShell updated your execution policy successfully, but the setting is overridden by a policy defined at a more specific scope. Due to the override, your shell will retain its current effective execution policy of Unrestricted. Type "Get-ExecutionPolicy -List" to view your execution policy settings. For more information please see "Get-Help Set-ExecutionPolicy".

There are solutions to similar problems here, here and here, however, they don't help me. The difference seems to be the following:

Those answers solve the case when the user does not have enough permissions. However, in my case, we have a global group policy that forces an 'Unrestricted' execution policy (...yeah, I know).

So when Visual Studio tries to set process permissions for its NuGet console or NuGet backend to RemoteSigned, it fails because the global, more permissive setting overrides this. This seems to cause an error that makes NuGet fail completely:

  1. If I open the Package Manager Console in VS, the red error message appears, but no prompt.
  2. If I try to install a package using the GUI, package installation fails because it cannot run the ..../install.ps1 script.

I tried starting VS as an administrator, manually setting all ExecutionPolicies I can modify as local (non-domain) admin to either Unrestricted or RemoteSigned, and repairing the VS install.

Using Get-ExecutionPolicy -List, I get the following Output:

MachinePolicy Unrestricted

UserPolicy Undefined

and Process, CurrentUser and LocalMachine are either undefined, or contain whatever value I set them to.

Note that the global unrestricted policy was in place before the VS upgrades, so either the install itself broke something, or the new versions have a different behavior.

How can I get Powershell/NuGet to work again?

Community
  • 1
  • 1
Wilbert
  • 7,251
  • 6
  • 51
  • 91
  • So, what does the `Get-ExecutionPolicy -list` return? What policy is not either `Undefined` or `Unrestricted`? Machine-wide? – Vesper Jul 22 '15 at 09:22
  • MachinePolicy Unrestricted, UserPolicy Undefined, the rest I can change and whatever I set them to, it doesn't resolve the problem. – Wilbert Jul 22 '15 at 09:30
  • Probably change error action to `SilentlyContinue` for `Set-ExecutionPolicy` call, so that its warning is not treated as an error. This is no error per se, it's an event that's generated when another policy of a higher level of impact is set. Actually I doubt that `Set-ExecutionPolicy` properly checks if the superseding policy is actually more restrictive than the one being set. – Vesper Jul 22 '15 at 09:53
  • Can you elaborate on how I can change the error action as you proposed? – Wilbert Jul 22 '15 at 09:55
  • You change the script that does `Set-ExecutionPolicy`, and add `-ErrorAction SilentlyContinue` to the cmdlet call. – Vesper Jul 22 '15 at 09:56
  • That's somewhere in the Visual Studio NuGet Plugin. I will try to find it. – Wilbert Jul 22 '15 at 09:58
  • Looks like i am not the only one [with this problem](http://stackoverflow.com/questions/31559268/nuget-crash-in-visual-studio-2015) (now with corrected link). – Wilbert Jul 22 '15 at 09:59
  • Here is the answer which works, but only until the restart(in the case of domain group policy) - http://stackoverflow.com/questions/31559268/nuget-crash-in-visual-studio-2015 – Maris Jul 22 '15 at 10:22
  • Yep, this means it's a double bug, one in Powershell `Set-ExecutionPolicy` that it throws warnings even if the superseding policy isn't more restrictive, and one in NuGet that it interpretes this warning as a critical error. – Vesper Jul 22 '15 at 11:06

0 Answers0