C# Visual Studio:将参数传递给编译器生成后事件中的可执行文件

C# Visual Studio:将参数传递给编译器生成后事件中的可执行文件,c#,visual-studio,post-build-event,C#,Visual Studio,Post Build Event,我正在尝试运行一个可执行文件,以在visual studio中的生成后事件中更改我的应用程序配置。根据配置是Debug还是Release,我希望将参数传递给可执行文件,以便正确执行配置更改器。以下是我所做的: if $(ConfigurationName) == Release ( "$(ProjectDir)ConfigurationGenerator\ConfigurationGenerator.exe" Release $(OutDir)applicationConfiguration.

我正在尝试运行一个可执行文件,以在visual studio中的生成后事件中更改我的应用程序配置。根据配置是Debug还是Release,我希望将参数传递给可执行文件,以便正确执行配置更改器。以下是我所做的:

if $(ConfigurationName) == Release 
(
"$(ProjectDir)ConfigurationGenerator\ConfigurationGenerator.exe" Release $(OutDir)applicationConfiguration.config 
)

if $(ConfigurationName) == Debug 
(
"$(ProjectDir)ConfigurationGenerator\ConfigurationGenerator.exe" Debug $(OutDir)applicationConfiguration.config
)

因此,在本例中,Debug和Release是参数1,$OutDirapplicationConfiguration.config是参数2。每次我尝试运行应用程序时,它都会使构建崩溃,并在错误列表窗口中返回我的应用程序,退出代码为3。有什么想法吗?

你需要有条件的回答吗?只需传入$Configuration


你已经描述了你所做的,但是你没有描述它的问题是什么。好的,我将编辑它,希望该实用程序不仅仅在失败时设置退出代码。在输出窗口中查找它发出的诊断消息。通常,您需要将文件路径参数放在双引号中,以便路径中的空格不会引起问题。退出代码有时等于Windows错误,3==未找到路径。我不确定您在这里试图解释什么。如果打开.csproj文件,这是PostBuildEvents存储的XML格式。好的,我试试it@MichaelNormand看看构建窗口的输出,正如Hans Passant指出的那样。它将显示完整的命令被传递给你的exe。我明白了!谢谢大家!
<PropertyGroup>
  <PostBuildEvent>
    Call "$(ProjectDir)ConfigurationGenerator\ConfigurationGenerator.exe" "$(Configuration)" "$(OutDir)applicationConfiguration.config"
  </PostBuildEvent>
</PropertyGroup>