简体   繁体   中英

Visual Studio: Pass Arguments to an Executable in the Compiler Post-Build Events

I'm trying to run an executable to change my application configuration in the post-build events in visual studio. Depending if the configuration is Debug or Release, I want to pass arguments to my executable in order to execute my configuration changer correctly. Here is what I've done:

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

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

So, the "Debug" and the "Release" are the argument #1 and the "$(OutDir)applicationConfiguration.config" is the argument #2 in this case. On each time that I try to run my applicatoin, it crashes the build and it returns me in the error lists window that my application stopped with the exit code 3. Any Idea?

Do you even need a conditional? Just pass in the $Configuration

<PropertyGroup>
  <PostBuildEvent>
    Call "$(ProjectDir)ConfigurationGenerator\ConfigurationGenerator.exe" "$(Configuration)" "$(OutDir)applicationConfiguration.config"
  </PostBuildEvent>
</PropertyGroup>

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