我们可以在 Visual Studio 中的构建后事件命令行中执行 .bat 文件吗?
我们可以在 Visual Studio 中的构建后事件命令行中执行 .bat 文件吗?
Can we execute a .bat file in post build event command line in visual studio?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当然,这里有一个示例:
请注意您可能遇到的两个可能的问题:
封闭的双引号(查看每个部分如何被
"
符号包围)如果您想调用 2 个或更多批处理文件,请确保使用
call
命令,否则您将得到一个很难找到第二个bat没有完成其工作的原因Sure, here's an example:
Just be aware of two possible issues you might have:
the enclosing double quotes (see how each part is surrounded by
"
sign)if you want to call 2 or more batch files make sure you use
call
command otherwise you'll have a trouble finding why the second bat is not doing its job是的,通过在构建后事件编辑器中添加对它的调用。
如果您转到项目的“属性”页面,则应选择“构建事件”选项卡。您可以在构建后事件命令行文本框中键入对批处理文件的调用。
如果您想使用项目或解决方案中包含的路径引用批处理文件,可以单击“编辑构建后...”按钮。这将打开“构建后事件命令行”对话框。
此对话框有一个可以单击的宏>>按钮。它将向您显示所有可用的宏,您可以使用它们来引用解决方案中的文件夹和文件。
当您选择这些宏之一时,您可以使用插入按钮将它们插入到脚本中。
Yes, by adding a call to it in the post-build event editor.
If you go to the Properties page for your project, you should select the Build Events tab. You can type in the call to your batch file in the Post-build event command line text box.
If you want to refer to the batch file using the paths included in the project or solution, you can click on the Edit Post-Build... button. This will open the Post-build Event Command Line dialog box.
This dialog box has a Macros >> button that you can click. It will show you all the available Macros that you can use to refer to folders and files within your solution.
When you select one of those macros, you can use the Insert button to insert them into your script.
除了调用 .bat 文件之外,您还可以直接在预构建/构建后字段中输入批处理命令(即 Windows 控制台中可用的常规命令 - cmd.exe)。这可能更可取,因为这意味着您不必单独维护批处理文件,因为您的所有命令都将成为项目的一部分。
As well as calling a .bat file, you can enter batch commands (i.e., the normal commands available from the Windows console--cmd.exe) directly into the Pre-build/Post-build fields. This may be preferable as it means you do not have to maintain the batch file separately, as all your commands will be part of the project.