Powershell – Use NuGet PowerShell commandlets from outside Visual Studio

nugetpowershellvisual studio 2010

I was trying to use my favorite source control from the Package Manager console in Visual Studio 2010. I had issues described in another topic. For now the best answer is to move all command-line stuff from Visual Studio to bare PowerShell.

But this case the Visual Studio related commandlets are not working. For example, most crucial one — I cannot run Update-Database command from Entity Framework.

Is it possible to register somehow Visual Studio specific commandlets for the current project in PowerShell? Or make PowerShell automatically take current project context from the packages subfolder?

Best Answer

The NuGet PowerShell commands rely on being run from within Visual Studio so will not work outside in the normal PowerShell running from the command line.

You can however use migrate.exe which ships with the EntityFramework NuGet package and use that from the command line to update your database.

As a prototype I put together a way to use NuGet PowerShell commands from the normal PowerShell command line using SharpDevelop. Unfortunately at the moment the EntityFramework NuGet package does not work with SharpDevelop.

Another interesting project is StudioShell which provides a new DTE: drive inside Visual Studio but can also be used outside from the command line. I do not believe it supports NuGet PowerShell commands being run from the normal PowerShell command line.