Explorer
Explorer

Reputation: 149

VS 2015 - There was an error running the selected code generator - what is the solution for this Issue?

I Installed Visual Studio 2015 Enterprise Edition in offline mode using the Bootstrap Installer files of Visual Studio on Windows Server 2008 R2 64 Bit machine. While installing offline it could not install TypeScript as the package was missing from the Installation files but nevertheless VS 2015 got installed without this TypeScript (which requires Internet to download and can be added as extension later).

After successful installation of VS, when I created an empty MVC web application, I was unable to add a view from the Controller. Also, the Package Manager Console was opening but in Disabled mode else I could fix this. But to no avail.

Faced the below Error -

Error

There was an error running the selected code generator :
'Failed to initialize the PowerShell host. If your PowerShell
execution policy is set to AllSigned, open the Package
Manager Console to initialize the host first.'

Upvotes: 1

Views: 237

Answers (1)

Explorer
Explorer

Reputation: 149

SOLUTION / FIX :
The Quickest and most reliable fix to this issue is to install the Hotfix provided by Microsoft on GitHub for Nuget. Just re-installing the Nuget Package Manager extension did it for me. It is the Nuget Package Manager that is throwing this error while scaffolding the view. This is a known issue that was raised by developers in 2015 and the hotfix was made available the same month and year by Microsoft.

Download the below hotfix and simply install the .vsix extension of Nuget. Voila, the error is gone and you can go ahead with Development.
https://github.com/NuGet/Home/releases/download/3.1.1/NuGet.Tools.vsix

If you can't download it directly from above link then go to: https://github.com/NuGet/Home/releases and download the latest version of the nuget tools.vsix file from there. I installed the 3.3 version vsix.

For Visual Studio 2013 - the fix is here - https://github.com/NuGet/Home/releases/download/2.8.7/NuGet.Tools.vsix


For more details - refer https://github.com/NuGet/Home/issues/974

Note - I found that there are similar errors faced by others, but I did not face those specific errors. Some suggestions I might have not tried, because they were asking to edit the system registries - which is risky and only a way to work around the problem which can re-surface again. The Windows Power Shell feature was also in On state on this server, which otherwise fixed the issue for some. The nuget vsix solution was one of the first ones I found for the exact error faced by me and it worked for me.

Upvotes: 1

Related Questions