2

My post-build event is:

"$(DevEnvDir)TF.exe" checkout "$(TargetPath)"

This checks out the target build assembly file. This is what I want, and it works great in VS.

On the build server, $(DevEnvDir) is equal to *Undefined*. So, I modified my post-build event to the following:

IF NOT "$(DevEnvDir)" == '*Undefined*' "$(DevEnvDir)TF.exe" checkout "$(TargetPath)"

The problem is, it still evaluates to see if $(DevEnvDir)TF.exe is an executable, and on the build server it evaluates to *Undefined*TF.exe, which throws this error:

'"*Undefined*TF.exe"' is not recognized as an internal or external command, operable program or batch file.

How can I conditionally execute this statement without it evaluating if the executable exists first?

qJake
  • 16,821
  • 17
  • 83
  • 135

1 Answers1

0

To run a command conditionally like this, use PowerShell:

if ('$(DevEnvDir)' -ne '*Undefined*') { [System.Diagnostics.Process]::Start('$(DevEnvDir)TF.exe', 'checkout "$(TargetPath)"') }

And wrap it in a clean PS environment:

powershell -windowstyle hidden -nologo -noprofile if ('$(DevEnvDir)' -ne '*Undefined*') { [System.Diagnostics.Process]::Start('$(DevEnvDir)TF.exe', 'checkout "$(TargetPath)"') }
qJake
  • 16,821
  • 17
  • 83
  • 135