Home: The dreaded "Could not find file..." Problem just bit me again

Created on 24 May 2016  路  10Comments  路  Source: NuGet/Home

I tried to add a package to my solution today, received:

Severity Code Description Project File Line Suppression State
Error 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. 0

The rest of the day was wasted trying to recover an operational IDE with NuGet. I have tried:

Uninstall Nuget
Set-ExecutionPolicy Unrestricted (in Powershell ISE (X86) )
Restart VS2015
Install Nuget

However, no matter what I do I still can't run the package manager console, getting the dreaded:

Could not find file 'C:\Windows\SysWOW64\WindowsPowerShell\v1.0\typesv3.ps1xml'.
Could not find file 'C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Event.Format.ps1xml'.
Could not find file 'C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Event.Format.ps1xml'.

Can anyone help? By the way, I last successfully added a package in this manner using NuGet about two weeks ago.I am using VS2015 with all available updates on Windows 7.

Most helpful comment

Try this simple solution: open an administrator command prompt.

copy C:\windows\System32\WindowsPowerShell\v1.0*ps1xml C:\windows\SyswOW64\WindowsPowerShell\v1.0\

Close Visual Studio and open it again. Check Nuget Package manager Console.

All 10 comments

Are you able to install using the Visual Studio UI? (Right click on the project and select manage packages)

Try the NuGet powershell known issues here: https://docs.nuget.org/Release-Notes/Known-Issues

And this thread:
http://stackoverflow.com/questions/12638289/embedding-powershell-v2-0-in-net-app-on-windows-8-rtm

Any luck with this? I'm also having this problem.

This fix doesn't seem to work for me: http://stackoverflow.com/questions/12638289/embedding-powershell-v2-0-in-net-app-on-windows-8-rtm

No, I was not able to find a solution. It's pretty sad, but when I need to maintain packages, I log out of VS2015, and log into VS2013. Then I update the packages in VS2013 and log out of VS2013 and log into VS2015 and resume regular programming.

I reproduced this error by running the x86 version of PowerShell.

I was able to resolve this problem by installing (or reinstalling) PowerShell from here https://www.microsoft.com/en-us/download/details.aspx?id=50395 (choosing this version: Win7AndW2K8R2-KB3134760-x64.msu for my windows 7 machine) and restarting.

I guess Visual Studio is using x86 powershell rather than x64 and that the x86 version was somehow corrupted.

@edvowles did you install powershell on the machine yourself originally, or was this a standard windows 7 environment?

@emgarten I'm using a laptop that I inherited from someone else. I suspect it hasn't had powershell installed separately to anything that comes with windows 7 or visual studio but I don't know.

Thanks, @edvowles, that worked!

@edvowles worked for me as well, thank you!

Try this simple solution: open an administrator command prompt.

copy C:\windows\System32\WindowsPowerShell\v1.0*ps1xml C:\windows\SyswOW64\WindowsPowerShell\v1.0\

Close Visual Studio and open it again. Check Nuget Package manager Console.

@tvmani your solution worked for me. Thanks!

Was this page helpful?
0 / 5 - 0 ratings