首页 > 解决方案 > 构建时调用 exe 包括命令名称和参数

问题描述

我需要在 Pre-build 事件中调用 *.exe 文件并为 *.exe 定义命令和参数。我试着这样做:

  <PropertyGroup>
    <PreBuildEvent>cmd /c D:\...\File.exe commandname -tt="option" -opt="option2"</PreBuildEvent>
  </PropertyGroup>

当我开始重建时,什么也没发生。应用程序重建成功,但 .exe 从未调用。

UPD

我也试过这样,但-opt在执行时为空:

<PreBuildEvent>call D:\...*.exe generate -opt="option"</PreBuildEvent>

标签: c#build

解决方案


这个变体对我有用:

  <PropertyGroup>
    <PreBuildEvent>"some.exe" "somecommand" "-opt=some option" "-opt2=one more opt"
</PreBuildEvent>
  </PropertyGroup>

推荐阅读