ElektroStudios
ElektroStudios

Reputation: 20474

Error: Can't install nuget package because of “Failed to initialize the PowerShell host”

Im having an error of Can't install nuget package because of “Failed to initialize the PowerShell host” when trying to implement PostSharp through nuget package, when I try to compile/run a project that uses PostSharp automatically opens a PostSharp kind of Wizard Screen that advises me that I should update the packages via Nuget, and then occurs the error.

My OS is Windows 8.1 x64, and the thing is that I DON'T HAVE PowerShell installed, I removed it permanently by removing pre-installed packages from the OS (from the Windows Image before installing it) because PowerShell was a totally unneeded component for my experience (until now),

then I cannot or I don't know how to recover a PowerShell.exe (with all its dependencies) without resintalling the full SO, merging to find and copy all the needed files from a Virtual-Machine could be a nightmare?.

So, I cannot open an imaginary powershell instance to run this command that is supposed to solve the problem with nuget (as explained here: http://patrickdesjardins.com/blog/failed-to-initialize-the-powershell-host):

Set-ExecutionPolicy Unrestricted

I also tried to download and install Windows Management Framework 4.0 which is supposed to install Powershell v2.0 but one of that 3 msu packages says that is not applicable to my OS, and the other msu packages says something so strange about can't recognize the certificate or the signer (sory, I don't know the error message translation in English language).

What can I do to solve that NuGet's PostSharp problem? maybe is not necessary to have powershell at all?

Upvotes: 0

Views: 1064

Answers (2)

ElektroStudios
ElektroStudios

Reputation: 20474

To my surprise and benefit I solved it in an easy way just copying the contents of these directories from a Guest OS to my Host OS to "recover" PowerShell functionality or better said NuGet functionality in VisualStudio.

C:\Windows\System32\WindowsPowerShell\v1.0
C:\Windows\SysWOW64\WindowsPowerShell\v1.0

Simply as that, copy & paste contents and now I can update/download Postsharp without any kind of error, it properly downloads the packages.

Upvotes: 0

Tim
Tim

Reputation: 2922

Hate to say it, but you are out of luck. Powershell is required to use nuget, and if you maimed Windows you will have to reinstall.

Word to the wise. Never muck with the internals of what Windows installs for packages aside from unchecking them in the wizard. Eventually you will need some software that needs that component, and you will be cursing when it happens. I say this also from a position of experience, so don't take it too harshly... Lol.

Upvotes: 2

Related Questions