简体   繁体   English

我可以让Visual Studio 2013在“文件保存”上运行Powershell命令吗?

[英]Can I have Visual Studio 2013 run a Powershell command on File Save?

I have a powershell window constantly open, so that when I'm making edits to files that don't require recompile (like angular pages, Views, configs, images, etc), I can just run a command (I call it 'Sync'), and it will copy over the files I changed to my build directory, without having to do a Build. 我有一个不断打开的Powershell窗口,因此当我对不需要重新编译的文件(例如,角度页面,视图,配置,图像等)进行编辑时,我只需运行命令即可(我称其为“同步” '),它将复制我更改到构建目录的文件,而无需进行构建。

Is it possible to have Visual Studio run that command when I do a Ctrl + S , or Ctrl + Shift + S ? 当我执行Ctrl + SCtrl + Shift + S时,是否可以让Visual Studio运行该命令? The amount of time to Alt + Tab to the new window, run the command, then tab to the browser, seems inconsequential, but I do it dozens, if not hundreds, of times a day, and I know it would save time. Alt + Tab到新窗口,运行命令,再到浏览器的Tab的时间似乎无关紧要,但是我每天这样做数十次(如果不是几百次),我知道这样可以节省时间。

I'm not aware of an easy way to do this completely automatically on file save, but you may be able save yourself some trouble by using External Tools (under Tools / External Tools). 我不知道一种在保存文件时完全自动执行此操作的简便方法,但是您可以使用“外部工具”(在“工具” /“外部工具”下)为自己省去一些麻烦。

It's possible to substitute macros for things like the full path to the current file, etc. You get a menu item under Tools, and you can assign a keyboard shortcut to it. 可以用宏代替当前文件的完整路径等内容。您可以在“工具”下找到一个菜单项,并可以为其分配键盘快捷键。

在此处输入图片说明

Sounds like a job for a Visual Studio add-in. 听起来像是Visual Studio外接程序的工作。 See this blog post by Scott Hanselman on how to write one. 请参阅Scott Hanselman的这篇博客文章 ,内容涉及如何编写。

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

相关问题 我可以在 Visual Studio 2010/2012/2013 中保存窗口布局吗? - Can I save the window layout in Visual Studio 2010/2012/2013? Visual Studio 2013部署文件保存 - Visual studio 2013 deploy file on save 如何将 PowerShell 与 Visual Studio 命令提示符一起使用? - How can I use PowerShell with the Visual Studio Command Prompt? 使用 PowerShell 在 Visual Studio 中保存文件 - use PowerShell to save file in Visual Studio 如何仅在Visual Studio中保存时才能构建TypeScript - How can I have TypeScript build only on save in Visual Studio 无法在visual studio 2013中打开HTML文件 - Can not open HTML file in visual studio 2013 Visual Studio 2013无法保存,构建或重建解决方案 - Visual Studio 2013 Can't save, build, or rebuild solution 如何在Visual Studio 2013中进行多级分类的单元测试? - How can I have multi-level categorized unit tests in visual studio 2013? 如何在正常的PowerShell会话中(不在Visual Studio中)运行Nuget PowerShell cmdlet Install-Package? - How can I run Nuget PowerShell cmdlet Install-Package in normal PowerShell session (not inside Visual Studio)? 如何在Visual Studio 2015的C#项目中运行简单的Powershell命令? - How do I run a simple Powershell command from my C# project in Visual Studio 2015?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM