简体   繁体   中英

Creating a Visual Studio 2013 extension that hosts PowerShell

Much of my build process is a collection of PowerShell scripts and functions, all defined within a .ps1 file. I simply have a shortcut to that file on my desktop, and it launches PowerShell and initializes everything.

Now, I think it would be handy if I could just run that shell within the Visual Studio 2013 environment. That way, I wouldn't need to keep switching windows when I want to build, publish things to IIS, perform database provisioning, etc. Should be easy enough, right?

The first thing I found was PowerConsole , an extension for Visual Studio that allows users to access Power Shell from within VS. However, it only works with Visual Studio 2010. According to the author , the NuGet team basically forked his code and it's now part of the NuGet console. So, my next idea was to just use the NuGet console. This has a few problems:

  1. It's called the "Package Manager Console" and hidden away in some menu. I want something easy to get to and clear that it's a build environment for my product.
  2. While you can run PowerShell commands such as dir , it doesn't really behave like PowerShell. For example, you can't change the prompt, even if you override the prompt function.
  3. There doesn't seem to be a way to override the profile. When I run my BuildShell.ps1 file, none of the functions within the file are registered and nothing seems to change.

Overall, this seems like a hacky way to integrate a custom build environment into Visual Studio. So, next step is to create my own extension. After all, that's all NuGet is, right?

The Question:

How do you create a NuGet like extension for Visual Studio 2013? MSDN has quite a few Visual Studio 2013 Extension samples , however they seem to be geared around extending the editor (such as what reSharper might do) and not creating new command windows. I'm looking for something to get me started, or perhaps an open source program I can look at. Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM