I'm trying to figure out why my builds are failing, so in a .proj that the build calls I added:
<Message Text="System Drive: $(SystemDrive)"/>
<Message Text="BuildAgtentId: $(BuildAgentId)" />
<Message Text="BuildDefinitionPath: $(BuildDefinitionPath)" />
<Message Text="SourceDir: $(SourceDir)" />
<Message Text="SrcDir: $(SrcDir)" />
<Message Text="BuildDefinitionPath: $(BuildDefinitionPath)." />
<Message Text="BuildDefinitionId: $(BuildDefinitionId)." />
<Message Text="TF_BUILD_BUILDDIRECTORY: $(TF_BUILD_BUILDDIRECTORY)" />
Now in doing this I assumed that $(SourceDir) would resolve to C:\Builds\$(BuildDefinitionId) since that's what I have in my Working Directory setting for my agent. I also set a variable in the MSBuild Parameters:
/p:SrcDir=$(SourceDir)
But when the .proj runs here's my output:
System Drive: C:
BuildAgtentId:
BuildDefinitionPath:
SourceDir:
SrcDir: $(SourceDir)
BuildDefinitionPath: .
BuildDefinitionId: .
TF_BUILD_BUILDDIRECTORY: .
So it seems as only $(SystemDrive) persists during the build. And my parameter set in the MSBuild args doesn't even seem to be set correctly (SrcDir). How can I access these variables during the build so I know where my files will be? I need to call some other programs (i.e. attrib) and pass in the location of my files and nothing seems to persist.
Based on this article I thought for sure that TF_BUILDDIRECTORY would work but it doesn't.
I then tried using this article that says that this should work:
<GetBuildProperties TeamFoundationServerUrl="$(TFSTeamFoundationServerUrl)" BuildUri="$(BuildUri)">
<Output TaskParameter="BuildDirectory" PropertyName ="TFSBuildDirectory" />
<Output TaskParameter="TeamProject" PropertyName="TFSTeamProject" />
</GetBuildProperties>
<Message Text="BuildLocation: $(TFSBuildDirectory)." />
<Message Text="TeamProject: $(TFSTeamProject)."/>
And while TeamProject works, BuildDirectory does not. So I get this:
BuildLocation: .
TeamProject: MDRVIDEOTOUCH.
You need to use the XAML build environment variables.
Some of those values aren't available, but you can get some of them: