本文整理汇总了C#中CodeActivityContext.TrackBuildMessage方法的典型用法代码示例。如果您正苦于以下问题:C# CodeActivityContext.TrackBuildMessage方法的具体用法?C# CodeActivityContext.TrackBuildMessage怎么用?C# CodeActivityContext.TrackBuildMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeActivityContext
的用法示例。
在下文中一共展示了CodeActivityContext.TrackBuildMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunProcess
private int RunProcess(CodeActivityContext context, string fullPath, string workingDirectory, string arguments)
{
context.TrackBuildMessage("fullPath: " + fullPath, BuildMessageImportance.Low);
context.TrackBuildMessage("workingDir: " + workingDirectory, BuildMessageImportance.Low);
context.TrackBuildMessage("arguments: " + arguments, BuildMessageImportance.Low);
using (Process proc = new Process())
{
proc.StartInfo.FileName = fullPath;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.Arguments = arguments;
context.TrackBuildMessage("Running " + proc.StartInfo.FileName + " " + proc.StartInfo.Arguments, BuildMessageImportance.High);
if (!string.IsNullOrEmpty(workingDirectory))
{
proc.StartInfo.WorkingDirectory = workingDirectory;
}
proc.Start();
string outputStream = proc.StandardOutput.ReadToEnd();
if (outputStream.Length > 0)
{
context.TrackBuildMessage(outputStream, BuildMessageImportance.Normal);
}
string errorStream = proc.StandardError.ReadToEnd();
if (errorStream.Length > 0)
{
context.TrackBuildError(errorStream);
}
proc.WaitForExit();
context.TrackBuildMessage("Exit Code: " + proc.ExitCode, BuildMessageImportance.Low);
return proc.ExitCode;
}
}
示例2: Execute
/// <summary>
/// Executes the activity
/// </summary>
/// <param name="context">The activity's context</param>
protected override void Execute(CodeActivityContext context)
{
//context.Track(new CustomTrackingRecord("olalá", TraceLevel.Info));
context.TrackBuildMessage("Starting", BuildMessageImportance.High);
//context.TrackBuildError("Starting");
WorkingFolder workingFolder =
Workspace.Get(context).GetWorkingFolderForServerItem(SourcesDirectory.Get(context));
var sourcesDirectory = workingFolder.LocalItem;
context.TrackBuildWarning(string.Format("Getting js files from {0}", sourcesDirectory), BuildMessageImportance.High);
var jsFiles = Directory.GetFiles(sourcesDirectory, "*.js");
foreach (var jsFile in jsFiles)
{
context.TrackBuildWarning(string.Format("Passing tests from {0}", jsFile), BuildMessageImportance.High);
}
}
示例3: Execute
protected override void Execute(CodeActivityContext context)
{
string resultFileToPublish = this.ResultFileToPublish.Get(context);
string resultTrxFile = Path.Combine(Path.GetDirectoryName(resultFileToPublish), Path.GetFileNameWithoutExtension(resultFileToPublish) + ".trx");
if (!File.Exists(resultFileToPublish))
{
//this could be normal if there were no tests in the file
context.TrackBuildMessage("Could not find results file: " + resultFileToPublish +", skipping publish activity", BuildMessageImportance.Low);
return;
}
this.TransformNUnitToMSTest(context, resultFileToPublish, resultTrxFile);
var buildDetail = context.GetExtension<IBuildDetail>();
string collectionUrl = buildDetail.BuildServer.TeamProjectCollection.Uri.ToString();
string buildNumber = buildDetail.BuildNumber;
string teamProject = buildDetail.TeamProject;
string platform = BuildSettings.Get(context).PlatformConfigurations[0].Platform;
string flavor = BuildSettings.Get(context).PlatformConfigurations[0].Configuration;
this.PublishMSTestResults(context, resultTrxFile, collectionUrl, buildNumber, teamProject, platform, flavor);
}
示例4: TransformNUnitToMSTest
private void TransformNUnitToMSTest(CodeActivityContext context, string nunitResultFile, string mstestResultFile)
{
context.TrackBuildMessage("input file: " + nunitResultFile);
context.TrackBuildMessage("output file: " + mstestResultFile);
Stream s = this.GetType().Assembly.GetManifestResourceStream("CustomBuildActivities.NUnitToMSTest.xslt");
if (s == null)
{
context.TrackBuildError("Could not load NUnitToMSTest.xslt from embedded resources");
return;
}
using (var reader = new XmlTextReader(s))
{
XslCompiledTransform transform = new XslCompiledTransform();
transform.Load(reader);
transform.Transform(nunitResultFile, mstestResultFile);
}
}
示例5: Execute
/// <summary>
/// Execute Activity
/// </summary>
/// <param name="context">code activity context </param>
protected override void Execute(CodeActivityContext context)
{
if (context == null)
{
throw new ArgumentNullException("context");
}
var directoryInfo = context.GetValue(this.BaseDirectory);
if (!directoryInfo.Exists)
{
return;
}
var searchDescription = context.GetValue(this.SearchDescription);
var fileExtensions = context.GetValue(this.FileExtensions);
var searchStrings = context.GetValue(this.SearchStrings);
if (searchStrings == null || searchStrings.Length == 0)
{
return;
}
var matches = directoryInfo.Search(fileExtensions, searchStrings);
// Write to build outputs log
context.TrackBuildMessage(string.Format("{0}: {1} items found.", searchDescription, matches.Count), BuildMessageImportance.High);
foreach (var match in matches)
{
var fileAndLine = string.Format("{0} ({1})", match.File.Name, match.LineNumber);
context.TrackBuildMessage(string.Format("{0,-50} {1}", fileAndLine, match.LineText.Trim()), BuildMessageImportance.High);
}
// Set output
this.MatchCount.Set(context, matches.Count);
}