简体   繁体   English

创建承载PowerShell的Visual Studio 2013扩展

[英]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. 我的构建过程大部分是PowerShell脚本和函数的集合,所有这些都在.ps1文件中定义。 I simply have a shortcut to that file on my desktop, and it launches PowerShell and initializes everything. 我在桌面上只是该文件的快捷方式,它会启动PowerShell并初始化所有内容。

Now, I think it would be handy if I could just run that shell within the Visual Studio 2013 environment. 现在,我认为如果可以 Visual Studio 2013环境中运行该Shell会很方便。 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? 这样,当我要构建,将内容发布到IIS,执行数据库配置等操作时,就不需要保持切换窗口的状态。应该足够容易,对吧?

The first thing I found was PowerConsole , an extension for Visual Studio that allows users to access Power Shell from within VS. 我发现的第一件事是PowerConsole ,它是Visual Studio的扩展,允许用户从VS中访问Power Shell。 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. 但是,它仅适用于Visual Studio2010。 根据作者的说法 ,NuGet团队基本上是在分叉他的代码,现在它已成为NuGet控制台的一部分。 So, my next idea was to just use the NuGet console. 因此,我的下一个想法是仅使用NuGet控制台。 This has a few problems: 这有几个问题:

  1. It's called the "Package Manager Console" and hidden away in some menu. 它被称为“ Package Manager控制台”,并隐藏在某些菜单中。 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. 尽管您可以运行PowerShell命令(例如dir ,但实际上它的行为并不像PowerShell。 For example, you can't change the prompt, even if you override the prompt function. 例如,即使您覆盖了prompt功能,也无法更改prompt
  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. 当我运行BuildShell.ps1文件时,该文件中的所有功能均未注册,并且似乎没有任何变化。

Overall, this seems like a hacky way to integrate a custom build environment into Visual Studio. 总的来说,这似乎是一种将自定义生成环境集成到Visual Studio中的简单方法。 So, next step is to create my own extension. 因此,下一步是创建自己的扩展程序。 After all, that's all NuGet is, right? 毕竟,这就是NuGet的全部,对吧?

The Question: 问题:

How do you create a NuGet like extension for Visual Studio 2013? 如何为Visual Studio 2013创建类似NuGet的扩展? 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. MSDN有很多Visual Studio 2013 Extension示例 ,但是它们似乎旨在扩展编辑器(例如reSharper可能执行的操作)并且不创建新的命令窗口。 I'm looking for something to get me started, or perhaps an open source program I can look at. 我正在寻找使我入门的东西,或者我可以看的开源程序。 Thanks! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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