qui*_*uip 16 visual-studio-2010 visual-studio
我想在不离开Visual Studio的情况下轻松运行批处理文件.批处理文件并不总是相同,它们会根据我正在使用的解决方案而改变.
我知道您可以在Visual Studio的"工具"部分(在"外部工具"下)创建自定义快捷方式.
我的解决方案有各种脚本/批处理文件,我希望有一种方法可以在解决方案文件夹或其他特定于解决方案的地方创建快捷方式.
我可以创建脚本,但似乎没有办法运行脚本.我不想每次要运行脚本时都要打开Windows资源管理器.
也许是一个加载项,它将使用解决方案资源管理器中的选定文件启动进程?或类似的东西?
C J*_*son 12
最好的方法是编写外部工具,然后根据当前加载的解决方案传入参数.
您可以将许多项目和解决方案特定变量传递给外部工具.打开"外部工具"对话框,然后在列表框中选择您的工具.您将看到外部工具的标题,以及指向要调用的脚本或批处理脚本的命令.参数编辑框旁边有一个按钮,旁边有一个箭头.单击箭头,您将看到一个可以传递给外部工具的变量或参数的大列表.
因此,例如,您可以使用以下内容:
$(ProjectDir) - 您正在处理的项目的完整路径目录.例如"C:\ builds\myproject"
$(ProjectPath) - 您正在处理的vcproj的完整路径名.例如"C:\ builds\myproject\foo.vcproj"
$(ProjectName) - 项目的名称.例如"foo"
$(SolutionDir) - 当前加载的解决方案的完整路径目录.例如"C:\ builds\mysolution"
等等...
Ink*_*art 11
以下是关于如何通过右键单击文件添加外部工具来运行批处理文件的完整步骤,并选择"运行批处理文件",也可以在需要编辑文件时打开并编辑它.
这是怎么做的......
创建一个名为"运行批处理文件"的外部工具
1) From Tools-> External Tools, create a new and put the below parameters:
2) Set the Command to: CMD.EXE
3) Set the Arguments to: /c "$(ItemPath)"
4) Set the Initial directory to: $(ItemDir)
5) ![DO NOT Check the "use output window" check box and then Apply to create the command
Note where the new command appeared in the list of commands.
The external commands are numbered from 1 starting below the divider bar.
#1 is usually "Create GUID"
To make it easy to remember you can move the new command to the top, to be the number one command in the list.][1]
6) Now go to Tools -> Customize and select the commands tab.
7) Select the Context menu radio button and select "Project and Solution Context menus | Item" from the drop down.
8) Now use "Add Command..." to add a new command
9) In the Categories list select "Tools"
10) From the commands select the "External Command #" that corresponds to the position of the "Run Batch file" custom command you noted the number of in step 5 above.
11) Move it to the right position in the list add keyboard short cuts etc.
12) Close the dialogue.
Run Code Online (Sandbox Code Playgroud)
现在右键单击批处理文件,您应该看到"运行批处理文件"菜单项.这将执行批处理文件并在VS Output窗口中显示它的输出.
希望能帮助到你.


| 归档时间: |
|
| 查看次数: |
20125 次 |
| 最近记录: |