0

How to Exec Command in MSBuild only if

This is my project

... 
<Exec Command='"my.exe"'\>
<Exec Command='"echo 1 > log.txt"'\>
...

What I want to do is execute echo depending on what my.exe "finds"/"say", like a if. What is the proper way to do this?

I'm thinking maybe something like

...
<Exec Command='"my.exe"'\> // will set a environment variables %CheckThis%=1\>
<Exec Command="my.exe" Condition="'$(CheckThis)' == '1'" />
...

What is the proper way to do this?

Oliver Spryn
  • 16,871
  • 33
  • 101
  • 195
Gerald Hughes
  • 5,771
  • 20
  • 73
  • 131
  • 1
    Don't use environment variables to communicate between processes, that is not at all what they are meant for. Make your exe return an exit code to indicate status instead, or make it log to standard output or to a file. Then handle that in msbuild. – stijn Feb 14 '14 at 12:00
  • +1 @stijn. If you articulate what my.exe is supposed to do or have the original code for my.exe, you can place this in a task and trap the outputs so that you're not using the command shell to store state. – Nicodemeus Feb 14 '14 at 14:04

0 Answers0