【发布时间】:2018-03-11 17:27:04
【问题描述】:
我正试图找出我的构建失败的原因,所以在我添加的构建调用的 .proj 中:
<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)" />
现在在执行此操作时,我假设 $(SourceDir) 将解析为 C:\Builds\$(BuildDefinitionId),因为这是我的代理工作目录设置中的内容。我还在 MSBuild 参数中设置了一个变量:
/p:SrcDir=$(SourceDir)
但是当 .proj 运行时,这是我的输出:
System Drive: C:
BuildAgtentId:
BuildDefinitionPath:
SourceDir:
SrcDir: $(SourceDir)
BuildDefinitionPath: .
BuildDefinitionId: .
TF_BUILD_BUILDDIRECTORY: .
所以在构建过程中似乎只有 $(SystemDrive) 存在。而且我在 MSBuild args 中设置的参数似乎甚至没有正确设置(SrcDir)。如何在构建过程中访问这些变量,以便知道我的文件在哪里?我需要调用一些其他程序(即 attrib)并传入我的文件的位置,但似乎没有什么能持续存在。
根据this 文章,我确信 TF_BUILDDIRECTORY 会起作用,但它不起作用。
然后我尝试使用 this 文章说这应该有效:
<GetBuildProperties TeamFoundationServerUrl="$(TFSTeamFoundationServerUrl)" BuildUri="$(BuildUri)">
<Output TaskParameter="BuildDirectory" PropertyName ="TFSBuildDirectory" />
<Output TaskParameter="TeamProject" PropertyName="TFSTeamProject" />
</GetBuildProperties>
<Message Text="BuildLocation: $(TFSBuildDirectory)." />
<Message Text="TeamProject: $(TFSTeamProject)."/>
虽然 TeamProject 有效,但 BuildDirectory 无效。所以我明白了:
BuildLocation: .
TeamProject: MDRVIDEOTOUCH.
【问题讨论】:
标签: tfs msbuild tfsbuild xamlbuild