XAML 构建在构建开始时标记了源,而 vNext 构建似乎在构建结束时标记。我注意到了,因为我在构建过程中修改/签入/标签文件。如果我让 vNext 标记构建,它会将我在签入后应用于文件的标签移动到以前的版本(在 GetSources 中使用的版本)。
但是我在任何日志文件中都没有看到 vNext 的标签。我错过了吗?我将不得不在 vnext 中禁用标签并在我的 msbuild 脚本中执行此操作...
编辑:在 vnext 构建定义中禁用标签并创建一个 msbuild 内联任务来标记工作区的源。现在我可以在构建开始时标记所有源,并为在构建期间修改的文件移动标签:)
如果有人想做类似的事情,这是我的内联任务:
<!--
TaskName="LabelWorkspaceSources"
- input: TfexeFullPath is the path to tf.exe
- input: BaseDirectory is the mapped folder of the software to build
- input: Label to apply
- input: Version is the changeset to apply the label to
-->
<UsingTask TaskName="LabelWorkspaceSources" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<TfexeFullPath Required="true" />
<BaseDirectory Required="true" />
<Label Required="true" />
<Version Required="true" />
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs">
<![CDATA[
//--- get the workspace mapping ---
System.Diagnostics.Process tfProcess = new System.Diagnostics.Process();
tfProcess.StartInfo.FileName = TfexeFullPath;
tfProcess.StartInfo.Arguments = "workfold";
tfProcess.StartInfo.UseShellExecute = false;
tfProcess.StartInfo.CreateNoWindow = true;
tfProcess.StartInfo.RedirectStandardOutput = true;
tfProcess.StartInfo.WorkingDirectory = BaseDirectory;
tfProcess.Start();
string output = tfProcess.StandardOutput.ReadToEnd();
tfProcess.WaitForExit();
string workfoldOutput = output.Trim();
Log.LogMessage(workfoldOutput, MessageImportance.High);
string[] linesWorkfoldOutput = workfoldOutput.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
List<string> mappedFolders = new List<string>();
Log.LogMessage("Trying to parse mapped folders.", MessageImportance.High);
foreach (string line in linesWorkfoldOutput)
{
//e.g. $/TPA: C:\TFS_Source\TPA
if (line.Contains("$/"))
{
string[] lineSplit = line.Split(new string[] { ": " }, StringSplitOptions.RemoveEmptyEntries);
//entry lineSplit[0] now contains the server path, lineSplit[1] contains the local folder
mappedFolders.Add(lineSplit[1]);
Log.LogMessage("Found mapped folder: " + lineSplit[1], MessageImportance.High);
}
}
//--- label all the mapped folders ---
foreach (string mappedFolder in mappedFolders)
{
tfProcess = new System.Diagnostics.Process();
tfProcess.StartInfo.FileName = TfexeFullPath;
tfProcess.StartInfo.Arguments = "label " + Label + " \"" + mappedFolder + "\" /child:replace /recursive /comment:\"Label created by task LabelWorkspaceSources\" /version:" + Version;
tfProcess.StartInfo.UseShellExecute = false;
tfProcess.StartInfo.CreateNoWindow = true;
tfProcess.StartInfo.RedirectStandardOutput = true;
tfProcess.StartInfo.WorkingDirectory = mappedFolder;
tfProcess.Start();
output = tfProcess.StandardOutput.ReadToEnd();
tfProcess.WaitForExit();
Log.LogMessage(tfProcess.StartInfo.Arguments, MessageImportance.High);
Log.LogMessage(output, MessageImportance.High);
}
]]>
</Code>
</Task>
</UsingTask>