How to Label Source upon successful build on Visual Studio Team Services

后端 未结 5 517
北恋
北恋 2021-01-17 15:25

I was trying to use new Build on Visual Studio Team Services (not XAML) but couldn\'t figure out how to label the source upon successful build. Any idea?

Below is t

5条回答
  •  孤城傲影
    2021-01-17 16:00

    The XAML build did label sources at the start of the build, while vNext build seems to label at the end of the build. I noticed that, because I modify/checkin/label files during the build. If I let vNext label the build, it moves the label that I have applied to the files after checkin to the previous version (the version that was used in GetSources).

    But I did not see the labeling of vNext in any logfile. Did I miss it? I will have to disable labeling in vnext and do it in my msbuild script...

    edit: Disabled labeling in vnext build definition and created an msbuild inline task to label the sources of the workspace. Now I can label all sources at the start of the build and move the label for files that were modified during the build :)

    If someone wants to do something similiar, here is my inline task:

    
    
        
            
            
            
        
            
             mappedFolders = new List();
    
            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);
            }
            ]]>
            
        
    
    

提交回复
热议问题