VS2008 构建后事件批处理文件

发布于 2024-09-15 15:04:34 字数 537 浏览 10 评论 0原文

我正在尝试执行批处理文件以在构建后移动一堆文件,因此我创建了一个如下所示的构建后事件:

$(ProjectDir)CopyPlugins.bat $(ConfigurationName)

问题是,当 Visual Studio 尝试运行该事件时,我收到错误进程 exited with code 9009

问题似乎是 VS 将整行放在引号中,以便它运行的命令是:

"C:\Users\kdmurray\Visual Studio 2008\Projects\Runner\Runner\CopyPlugins.bat Debug"

当然我打算做的是一个非常微妙的变化,改变右引号的位置。

"C:\Users\kdmurray\Visual Studio 2008\Projects\Runner\Runner\CopyPlugins.bat" Debug

有什么办法可以解决 VS 提供的这个相当烦人的“帮助”吗?

I'm trying to execute a batch file to move a bunch of files around after a build so I've created a post-build event that looks like this:

$(ProjectDir)CopyPlugins.bat $(ConfigurationName)

The problem is that when Visual Studio tries to run the event I get the error that the process exited with code 9009

The problem appears to be that VS puts the entire line in quotes so that the command it runs is:

"C:\Users\kdmurray\Visual Studio 2008\Projects\Runner\Runner\CopyPlugins.bat Debug"

Of course what I intended it to do was a very subtle variation, changing the location of the closing quotation mark.

"C:\Users\kdmurray\Visual Studio 2008\Projects\Runner\Runner\CopyPlugins.bat" Debug

Is there any way around this rather annoying "help" that VS provides?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

忆梦 2024-09-22 15:04:34

创建另外两个批处理文件,仅使用不同的参数执行第一个批处理文件。

复制Plugins-debug.bat
调用CopyPlugins.bat调试

CopyPlugins-release.bat
调用 CopyPlugins.bat 发布

并在 VS 构建后事件中
“$(ProjectDir)CopyPlugins-$(ConfigurationName).bat”

Create two more batch files that just executes the first with different arguments.

CopyPlugins-debug.bat
Call CopyPlugins.bat debug

CopyPlugins-release.bat
Call CopyPlugins.bat release

And in VS post-build event
"$(ProjectDir)CopyPlugins-$(ConfigurationName).bat"

凉世弥音 2024-09-22 15:04:34

如果您尝试进行复杂的构建后复制,可能值得查看 MSBuild Community Tasks 项目。它有一个包装 RoboCopy.exe 的任务,这可能是完成任务的更简洁的方法。

一般来说,我会创建一个单独的“构建”项目,该项目是空的,除了执行构建前/构建后步骤之外什么也不做。它运作得很好。

If you're trying to do complicated post-build copying it might be worth looking at the MSBuild Community Tasks project. It has a task that wraps RoboCopy.exe which might be a cleaner way to accomplish your task.

Generally I make a separate "build" project that is empty and does nothing but execute pre/post build steps. It works quite well.

不爱素颜 2024-09-22 15:04:34

我认为您可能只需要在批处理脚本的路径周围加上引号,即您的构建后事件应该是:

"$(ProjectDir)CopyPlugins.bat" $(ConfigurationName)

这对我来说适用于位于路径中有空格的目录中的 C# 项目。

I think you might just need quotes around the path to the batch script, i.e. your post-build event should be:

"$(ProjectDir)CopyPlugins.bat" $(ConfigurationName)

This worked for me for a C# project located in a directory with a space in its path.

喜你已久 2024-09-22 15:04:34

只需像这样输入

d:\foo\bar\myMainScript.bat "$(MY_VSPROPS_MACRO_VAR_00)"

这对我有用。不要使用CALL函数来调用批处理文件!

将所有参数传递到主批处理文件中并处理里面的内容。
如果您有其他批处理或一组批处理要调用,请不要在构建后事件中调用它们,只需从主批处理文件中调用其他批处理文件即可。

Just type it like this

d:\foo\bar\myMainScript.bat "$(MY_VSPROPS_MACRO_VAR_00)"

This worked for me. Dont use CALL function to call the batch file!!!.

Pass all the parameters into the main batch file and process things inside.
If you have other batches or set of batches to be called, don't call them in the post build event, just call the other batch files from the main batch file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文