Tuesday, February 23, 2016

TFS Build: Variable Expansion in Post Build Event of VS project

While building a VS Project in TFS 2015 Build system, I wrote one TFS variable in a Post Build Event command of my project as:.

Echo ***** BUILD_SOURCESDIRECTORY = %BUILD_SOURCESDIRECTORY% or $(BUILD_SOURCESDIRECTORY) ****

And from the log, I observed the before executing this command, it reads it as:

Echo **** BUILD_SOURCESDIRECTORY = %BUILD_SOURCESDIRECTORY% OR D:\Agents\Agent03\agent\_work\1\s **********

and when executed, it was like this:

**** BUILD_SOURCESDIRECTORY = D:\Agents\Agent03\agent\_work\1\s OR D:\Agents\Agent03\agent\_work\1\s ******

So concluding that:
  1. $(BUILD_SOURCESDIRECTORY) : Would be expanded to the value before or during build:
  2. %BUILD_SOURCESDIRECTORY%: Would be expanded during execution of script (bat in this case). 
  • %Variable% is the format used to evaluate variables  in bat/cmd scripts.








No comments: