Getting the System Root Directory during TFS Build was not straightforward as I thought, so I decided to share my experience on how to get that.
- I used the InvokeMethod activity. In the Target Type, I will put the name of the static class that has the method I need to use.
- In MethodName, I will put GetEnviornmentVariable.
- Write the value to the build log by calling WriteBuildError and passing the value returned from GetEnviornmentVariable.
Note: For InvokeMethod activity, if I need to call a method from an instance object, then I will use Target Object not Target Type.