本文整理汇总了C#中CodeActivityContext.WriteBuildMessage方法的典型用法代码示例。如果您正苦于以下问题:C# CodeActivityContext.WriteBuildMessage方法的具体用法?C# CodeActivityContext.WriteBuildMessage怎么用?C# CodeActivityContext.WriteBuildMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeActivityContext
的用法示例。
在下文中一共展示了CodeActivityContext.WriteBuildMessage方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunNuGetProcess
public bool RunNuGetProcess(string nuGetFilePath, string arguments, CodeActivityContext context)
{
var stopwatch = new Stopwatch();
stopwatch.Start();
var proc = new Process
{
StartInfo =
{
FileName = nuGetFilePath,
Arguments = arguments,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardError = true
}
};
proc.Start();
var errorOutput = proc.StandardError.ReadToEnd();
// Block for now but force release of the process after 5 minutes - Just in case NuGet fails to return
// otherwise it will return as soon as NuGet is done.
var result = proc.WaitForExit(300000);
stopwatch.Stop();
if (context != null)
{
if (!string.IsNullOrWhiteSpace(errorOutput))
{
result = false;
context.WriteBuildMessage(string.Format("Error reported in the NuGet Process: {0}", errorOutput), BuildMessageImportance.High);
}
context.WriteBuildMessage(string.Format("NuGet Process execution time: {0}", stopwatch.Elapsed.Seconds), BuildMessageImportance.High);
}
return result;
}
示例2: Execute
/// <summary>
/// Check in the files that were checked out and edited
/// </summary>
/// <param name="context"></param>
protected override void Execute(CodeActivityContext context)
{
// Get the workspace passed in as a property
var workspace = context.GetValue(Workspace);
// Get the list of changes that need to be made.
PendingChange[] pendingChanges = workspace.GetPendingChanges();
if ((pendingChanges == null) || (pendingChanges.Length == 0))
{
context.WriteBuildMessage("There are no changes pending - No CheckIn will be performed.", BuildMessageImportance.High);
}
else
{
context.WriteBuildMessage("Checking in pending changes", BuildMessageImportance.High);
// Need to check in the files without initiating a CI build: Passing on "***NO_CI***" as a comment does this
// see: http://blogs.msdn.com/b/buckh/archive/2007/07/27/tfs-2008-how-to-check-in-without-triggering-a-build-when-using-continuous-integration.aspx
workspace.CheckIn(workspace.GetPendingChanges(), null, "***NO_CI***", null, null,
new PolicyOverrideInfo(
"Checking in modified AssemblyInfo files as part of Versioning Build Process",
null), CheckinOptions.SuppressEvent);
}
}
示例3: Execute
// If your activity returns a value, derive from CodeActivity<TResult>
// and return the value from the Execute method.
protected override void Execute(CodeActivityContext context)
{
var dropFolder = DropFolder.Get(context);
var sourcesFolder = SourcesFolder.Get(context);
var binariesFolder = BinariesFolder.Get(context);
var powerShellScriptFilepath = PowerShellScriptFilepath.Get(context);
var nuGetPrePackageFolder = NuGetPrePackageFolder.Get(context);
context.WriteBuildMessage(string.Format("powerShellScriptFilepath: {0}", powerShellScriptFilepath), BuildMessageImportance.High);
context.WriteBuildMessage(string.Format("dropFolder: {0}", dropFolder), BuildMessageImportance.High);
context.WriteBuildMessage(string.Format("binariesFolder: {0}", binariesFolder), BuildMessageImportance.High);
context.WriteBuildMessage(string.Format("sourcesFolder: {0}", sourcesFolder), BuildMessageImportance.High);
// Call the PowerShell script
var result = ExecutePowerShellScript(powerShellScriptFilepath, dropFolder, binariesFolder, sourcesFolder, nuGetPrePackageFolder);
// Return the value back to the workflow
context.SetValue(Result, result);
}
示例4: Execute
/// <summary>
/// Searches an XML file with an XPath expression
/// </summary>
/// <param name="context"></param>
protected override void Execute(CodeActivityContext context)
{
// get the value of the XPathExpression
var xpathExpression = context.GetValue(XPathExpression);
// get the value of the FilePath
var filePath = context.GetValue(FilePath);
// get the value of the Namespace
var xmlNamespace = context.GetValue(XmlNamespace);
// get the value of the Namespace
var xmlNamespacePrefix = context.GetValue(XmlNamespacePrefix);
string elementValue;
try
{
elementValue = GetXmlElementValue(filePath, xpathExpression, xmlNamespace, xmlNamespacePrefix);
}
catch (FileNotFoundException fileNotFoundException)
{
context.WriteBuildMessage(string.Format("In XmlGetElement - {0} - File: {1}",
fileNotFoundException.Message, filePath), BuildMessageImportance.High);
throw;
}
// return the value
ElementValue.Set(context, elementValue);
}
示例5: Execute
protected override void Execute(CodeActivityContext context)
{
#region Workflow Arguments
var switchInvokePowerShell = SwitchInvokePowerShell.Get(context);
var powerShellScriptPath = PowerShellScriptPath.Get(context);
var nuGetExeFilePath = NuGetExeFilePath.Get(context);
var nuSpecFilePath = NuSpecFilePath.Get(context);
var basePath = BasePath.Get(context);
var outputDirectory = OutputDirectory.Get(context);
var version = Version.Get(context);
var switchInvokePush = SwitchInvokePush.Get(context);
var apiKey = ApiKey.Get(context);
var pushDestination = PushDestination.Get(context);
var additionalOptions = AdditionalOptions.Get(context);
#endregion
var resultMessages = SummarizePropertyValues(switchInvokePowerShell, powerShellScriptPath, nuGetExeFilePath,
nuSpecFilePath, basePath, outputDirectory, version, switchInvokePush, apiKey,
pushDestination, additionalOptions);
for (var i = 0; i < resultMessages.Length - 1; i++)
{
// Write to the log
context.WriteBuildMessage(resultMessages[i], BuildMessageImportance.High);
}
}
示例6: Execute
protected override void Execute(CodeActivityContext context)
{
#region Workflow Arguments
// The TFS source location of the file to get
var fileToGet = context.GetValue(FileToGet);
// The current workspace - used to create a new workspace for the get
var workspace = context.GetValue(Workspace);
// The local build directory
var buildDirectory = context.GetValue(BuildDirectory);
#endregion
// Version seed file and path
var versionFileDirectory = string.Format("{0}\\VersionSeed", buildDirectory);
var filename = Path.GetFileName(fileToGet);
var fullPathToSeedFile = Path.Combine(versionFileDirectory, filename);
// Return the value back to the workflow
context.SetValue(FullPathToSeedFile, fullPathToSeedFile);
// Write to the log
context.WriteBuildMessage(string.Format("Getting file from Source: {0}", fileToGet),
BuildMessageImportance.High);
context.WriteBuildMessage(string.Format("Placing version seed file in: {0}", versionFileDirectory),
BuildMessageImportance.High);
try
{
// Create workspace and working folder
var tempWorkspace = workspace.VersionControlServer.CreateWorkspace("VersionSeed");
var workingFolder = new WorkingFolder(fileToGet, fullPathToSeedFile);
// Map the workspace
tempWorkspace.CreateMapping(workingFolder);
// Get the file
var request = new GetRequest(new ItemSpec(fileToGet, RecursionType.None), VersionSpec.Latest);
var status = tempWorkspace.Get(request, GetOptions.GetAll | GetOptions.Overwrite);
if (!status.NoActionNeeded)
{
foreach (var failure in status.GetFailures())
{
context.WriteBuildMessage(
string.Format("Failed to get file from source: {0} - {1}", fileToGet,
failure.GetFormattedMessage()), BuildMessageImportance.High);
}
}
// Return the value back to the workflow
context.SetValue(FullPathToSeedFile, fullPathToSeedFile);
// Get rid of the workspace
tempWorkspace.Delete();
}
catch (Exception)
{
context.WriteBuildMessage(string.Format("Seed file exists in '{0}'. Using existing file.", versionFileDirectory),
BuildMessageImportance.High);
}
}
示例7: Execute
protected override void Execute(CodeActivityContext context)
{
#region Extract Workflow Argument Values
// The file path of the nuget.exe - if null or empty then
// assume nuget is "installed" on the build server and in the path
var nuGetExeFilePath = NuGetExeFilePath.Get(context);
// The path of the nuspec file
var nuSpecFilePath = NuSpecFilePath.Get(context);
// The folder location of the files to be packed
var basePath = BasePath.Get(context);
// The folder location of the files to be packed
var outputDirectory = OutputDirectory.Get(context);
// The destination location if deployment is to be done
var versionNumber = VersionNumber.Get(context);
// command line options to append (as is) to the nuget command line
var additionalOptions = AdditionalOptions.Get(context);
#endregion
context.WriteBuildMessage(string.Format("In CallNuGetPackageCommandLine:"), BuildMessageImportance.High);
context.WriteBuildMessage(string.Format("nuGetExeFilePath: {0}", nuGetExeFilePath), BuildMessageImportance.High);
context.WriteBuildMessage(string.Format("basePath: {0}", basePath), BuildMessageImportance.High);
context.WriteBuildMessage(string.Format("outputDirectory: {0}", outputDirectory), BuildMessageImportance.High);
context.WriteBuildMessage(string.Format("versionNumber: {0}", versionNumber), BuildMessageImportance.High);
context.WriteBuildMessage(string.Format("additionalOptions: {0}", additionalOptions), BuildMessageImportance.High);
// Don't assume that DI will have happened. If the value is null then create the default object.);)
if (NuGetProcess == null)
{
NuGetProcess = new NuGetProcess();
}
// Call the method that will do the work
var results = NuGetPackaging(nuGetExeFilePath, nuSpecFilePath, outputDirectory, basePath, versionNumber, additionalOptions, context);
// Send the result back to the workflow
NuGetPackagingResult.Set(context, results);
}
示例8: NuGetPackaging
/// <summary>
/// Does the NuGet Processing work. Formats data into an argument string and then calls NuGet.Exe
/// </summary>
/// <param name="nuGetExeFilePath">Full path to the nuget.exe application OR empty if nuget is in the machine's path</param>
/// <param name="nuSpecFilePath">path to the NuSpec "manifest" file</param>
/// <param name="outputDirectory">path to the folder where the generated NuPkg file should be placed</param>
/// <param name="basePath">path to the folder containing all of the files that should be packaged</param>
/// <param name="versionNumber">optional: is a version number is provided it will be used to override the version of the package</param>
/// <param name="additionalOptions">additional NuGet command line arguments (optional)</param>
/// <param name="context">the workflow/build context - used to send build messages</param>
/// <returns>true if the nuget process succeeds</returns>
public bool NuGetPackaging(string nuGetExeFilePath, string nuSpecFilePath, string outputDirectory, string basePath, string versionNumber, string additionalOptions, CodeActivityContext context)
{
var versionParameter = string.Empty;
#region Parameter Validation
if (string.IsNullOrWhiteSpace(nuSpecFilePath))
{
throw new ArgumentNullException("nuSpecFilePath");
}
if (string.IsNullOrWhiteSpace(basePath))
{
throw new ArgumentNullException("basePath");
}
if (string.IsNullOrWhiteSpace(outputDirectory))
{
throw new ArgumentNullException("outputDirectory");
}
#endregion
// If the version number was provided, then use it
if (!string.IsNullOrWhiteSpace(versionNumber))
{
versionParameter = string.Format("-version {0}", versionNumber);
}
var arguments = string.Format(
"pack \"{0}\" -OutputDirectory \"{1}\" -BasePath \"{2}\" {3} {4}", nuSpecFilePath, outputDirectory, basePath, versionParameter, additionalOptions).Trim();
if (context != null)
{
context.WriteBuildMessage(string.Format("CallNuGetPackageCommandLine arguments: {0}", arguments), BuildMessageImportance.High);
}
return NuGetProcess.RunNuGetProcess(NuGetHelper.ValidateNuGetExe(nuGetExeFilePath), arguments, context);
}
示例9: Execute
protected override void Execute(CodeActivityContext context)
{
#region Workflow Arguments
// This will be the api key or a path to the file with the key in it (or blank)
var apiKeyOrFile = ApiKeyOrFile.Get(context);
// The local build directory
var sourcesDirectory = SourcesDirectory.Get(context);
#endregion
string resultMessage;
var apiKey = ExtractApiKey(apiKeyOrFile, sourcesDirectory, out resultMessage);
// Write to the log
context.WriteBuildMessage(resultMessage, BuildMessageImportance.High);
// Return the value back to the workflow
context.SetValue(ApiKeyValue, apiKey);
}
示例10: Execute
protected override void Execute(CodeActivityContext context)
{
#region Workflow Arguments
// This will be the api key or a path to the file with the key in it (or blank)
var versionPatternOrSeedFilePath = VersionPatternOrSeedFilePath.Get(context);
// The local build directory
var packageId = PackageId.Get(context);
var sourcesDirectory = SourcesDirectory.Get(context);
#endregion
string versionPattern;
try
{
versionPattern = ExtractVersion(versionPatternOrSeedFilePath, packageId, QueryPackageId, sourcesDirectory);
}
catch (ArgumentException)
{
versionPattern = ExtractVersion(versionPatternOrSeedFilePath, packageId, QuerySolutionName, sourcesDirectory);
}
// Write to the log
context.WriteBuildMessage(string.Format("Version Pattern: {0}", versionPattern), BuildMessageImportance.Normal);
// Return the value back to the workflow
context.SetValue(VersionPattern, versionPattern);
}
示例11: Execute
/// <summary>
/// Searches an XML file with an XPath expression
/// </summary>
/// <param name="context"></param>
protected override void Execute(CodeActivityContext context)
{
// get the value of the XPathExpression
var fileNamePattern = FileNamePattern.Get(context);
// get the value of the FilePath
var searchFolder = SearchFolder.Get(context);
var filePath = FindFile(fileNamePattern, searchFolder);
context.WriteBuildMessage(string.Format("Path found: {0}", filePath), BuildMessageImportance.High);
// return the value
FullFilePath.Set(context, filePath);
}