Reputation: 31313
Using the following custom TFS activity I am attempting to get the sources directory from the WellKnownEnvironmentVariables.SourcesDirectory. However, it always returns null. How can I get the value of WellKnownEnvironmentVariables.SourcesDirectory from within the C# code of a custom activity (I don't want to pass the value in)?
public class MyActivity : CodeActivity
{
protected override void Execute(CodeActivityContext context)
{
var eve = new EnvironmentVariableExtension();
var sourcesDirectory = eve.GetEnvironmentVariable<string>(context, WellKnownEnvironmentVariables.SourcesDirectory);
}
}
I also tried this which returns null as well...
public class MyActivity : CodeActivity
{
protected override void Execute(CodeActivityContext context)
{
var sourcesDirectory = System.Environment.GetEnvironmentVariable("TF_BUILD_SOURCESDIRECTORY");
}
}
Upvotes: 2
Views: 2577
Reputation: 22245
If you want to get a value of an environment variable from your code, just use something like this:
System.Environment.GetEnvironmentVariable("TF_BUILD_SOURCESDIRECTORY")
Full list of TFS Build related environment variables can be found here: http://msdn.microsoft.com/en-ca/library/hh850448.aspx#program_or_script
Upvotes: 1