Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 550 Vote(s) - 3.51 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can't install nuget package because of "Failed to initialize the PowerShell host"

#1
All of a sudden, I am getting this error when upgrading Nuget packages. None of the fixes that I have come across work. I am using Visual Studio 2013.

> 'Newtonsoft.Json 6.0.3' already installed.
>
> Adding 'Newtonsoft.Json 6.0.3' to Tournaments.Notifications.
>
> Successfully added 'Newtonsoft.Json 6.0.3' to Tournaments.Notifications.
>
> Executing script file 'F:\My Webs\BasketballTournaments\MainBranch\packages\Newtonsoft.Json.6.0.3\tools\install.ps1'.
>
> Failed to initialize the PowerShell host. If your PowerShell execution policy setting is set to AllSigned, open the Package Manager Console to initialize the host first.

**Package Manager Console**

> Attempting to perform the InitializeDefaultDrives operation on the 'FileSystem' provider failed.

If I wait for the initialization to finish in the console I was able to add some packages.
Reply

#2
Remember to restart Visual Studio after you've done the `Set-ExecutionPolicy Unrestricted` in PowerShell (x86).

If that doesn't work, try `Set-ExecutionPolicy RemoteSigned` in PowerShell (x86) then restart Visual Studio.
Reply

#3
For me setting the execution policy to Unrestricted did not work. I had to **repair the vs2013** installation by going into Control Panel. Repairing the installation worked for me.
Reply

#4
This started happening with 6.0.4 recently for me, I don't think this is a very good solution but here is what helped me.
Close Visual Studio

1. Open a Windows PowerShell prompt as Administrator (very important) and run the following command:Set-ExecutionPolicy Bypass
2. Open Visual Studio, open your solution and use Nuget to install JSON.Net (or whatever package included it as a dependency).
3. Once everything is working, I recommend setting the powershell execution policy back to restricted with the following command:
Set-ExecutionPolicy Restricted
Reply

#5
All I needed to do was restart Visual Studio, open the NuGet `Package Manager Console`, and then using the `Manage NuGet Packages` dialog worked.
Reply

#6
Running the Visual Studio as Administrator worked for me.
Reply

#7
I have the same issue with the Manage NuGet Packages dialog, I use a work-around that may help others - running from package manager console:

If I use the command line powershell commandlet install-package, all is fine.

I am adverse to changing a security setting "just to make it work".
Reply

#8
Download and Install [Administrative Templates for Windows PowerShell][1]





[1]:

[To see links please register here]



Next: Powershell x86 from As Administrator

Run: Get-ExecutionPolicy -List , and see if you have RemoteSigned etc..

1. 5 different scopes Set-ExecutionPolicy "RemoteSigned" -Scope Process -Confirm:$false

2. Machine and User Policy you have to set through the Group Policy Administration Template in 2 areas.




**UPDATE - EDIT:**

Set ALL of them to "Undefined" and ONLY the LocalMachine to "Restricted"

This is what fixed might after I had given my powershell more permissions not knowing that it would mess up visual studio 2013 and 2015
Reply

#9
By default the PowerShell script execution is very limited for security reasons. For use within NuGet we need to open the doors.

**1. Step**

Open `Windows PowerShell`, run as `Administrator`

**2. Step**

NuGet is using the 32 bit console, so it wont be affected by changes to the 64 bit console. Run the following script to make sure you are configuring the 32 bit console.

start-job { Set-ExecutionPolicy RemoteSigned } -RunAs32 | wait-job | Receive-Job

**3. Step**

Restart `Visual Studio`
Reply

#10
No answers have worked for me.

All policies were correct but I have the error when installing a package

> Failed to initialize the PowerShell host. If your PowerShell execution
> policy setting is set to AllSigned, open the Package Manager Console
> to initialize the host first.



The **solution** : I have **uninstalled** the **nuget package manager** plugin and **reinstalled** it.

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through