简体   繁体   中英

How to run an exe on a post build event

在构建后事件上运行某个exe文件的正确脚本是什么?

Just as you would run this .exe from command-line. So, specify your .exe with full path and enclose it in double-quotes if either path or executable name contain spaces.

Provided answer is correct, however providing the full path is not always necessary.

Example: run one of the projects output executable.

  • (optionally) Configure post-build event to run Always
  • use a path relative to the project path. Eg: "$(ProjectDir)bin\\Debug\\maybe_just_refreshed.exe" or better version suggested by m93a : "$(TargetDir)maybe_just_refreshed.exe" (this compansates for the cases when output location is customized (not the default bin\\Debug ).

None of these answers worked for me.

Even though my exe was at the file path I provided, it still exited with a code of "whatever" and never worked.

Then I did this:

cd $(ProjectDir)

"MyProgram.exe"

...both on separate lines in the post build event command line editor.

My app is located in the project directory. They didn't work on the same line, but separate lines worked fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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