本文整理汇总了C#中Microsoft.Build.Framework.BuildMessageEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# BuildMessageEventArgs类的具体用法?C# BuildMessageEventArgs怎么用?C# BuildMessageEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BuildMessageEventArgs类属于Microsoft.Build.Framework命名空间,在下文中一共展示了BuildMessageEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogBuildEvents
public void LogBuildEvents()
{
// This event should only be logged when OnlyLogCriticalEvents is off
BuildMessageEventArgs messageEvent = new BuildMessageEventArgs("MyMessage", "HelpKeyword", "Sender", MessageImportance.High);
// These three should be logged when OnlyLogCritical Events is on or off
BuildWarningEventArgs warning = new BuildWarningEventArgs("SubCategoryForSchemaValidationErrors", "MSB4000", "file", 1, 2, 3, 4, "message", "help", "sender");
BuildErrorEventArgs error = new BuildErrorEventArgs("SubCategoryForSchemaValidationErrors", "MSB4000", "file", 1, 2, 3, 4, "message", "help", "sender");
ExternalProjectStartedEventArgs externalStartedEvent = new ExternalProjectStartedEventArgs("message", "help", "senderName", "projectFile", "targetNames");
ProcessBuildEventHelper loggingService = (ProcessBuildEventHelper)ProcessBuildEventHelper.CreateLoggingService(LoggerMode.Synchronous, 1);
// Verify when OnlyLogCriticalEvents is false
LogandVerifyBuildEvent(messageEvent, loggingService);
LogandVerifyBuildEvent(warning, loggingService);
LogandVerifyBuildEvent(error, loggingService);
LogandVerifyBuildEvent(externalStartedEvent, loggingService);
// Verify when OnlyLogCriticalEvents is true
loggingService.OnlyLogCriticalEvents = true;
loggingService.LogBuildEvent(messageEvent);
Assert.IsNull(loggingService.ProcessedBuildEvent, "Expected ProcessedBuildEvent to be null");
LogandVerifyBuildEvent(warning, loggingService);
LogandVerifyBuildEvent(error, loggingService);
LogandVerifyBuildEvent(externalStartedEvent, loggingService);
}
示例2: LogMessage
public static void LogMessage(this ITask task,string message, params object[] messageArgs)
{
var buildEngine = task.BuildEngine;
BuildMessageEventArgs e = new BuildMessageEventArgs(string.Format(message, messageArgs), (string)null, task.GetType().Name, MessageImportance.Normal);
buildEngine.LogMessageEvent(e);
}
示例3: WriteInternal
protected override void WriteInternal(WriteStyle style, string value)
{
// TODO: How do we normalize this with the current design? Perhaps hold lines without a line end until we get one?
// MSBuild ALWAYS is a "Writeline"
value = value.Trim('\f', '\n', '\r');
if (string.IsNullOrWhiteSpace(value)) { return; }
if (style.HasFlag(WriteStyle.Error))
{
LogError(value);
}
else if (style.HasFlag(WriteStyle.Critical))
{
LogWarning(value);
}
else
{
MessageImportance importance = MessageImportance.Normal;
if (style.HasFlag(WriteStyle.Bold) || style.HasFlag(WriteStyle.Important))
{
importance = MessageImportance.High;
}
BuildMessageEventArgs message = new BuildMessageEventArgs(
message: value,
helpKeyword: null,
senderName: _taskName,
importance: importance);
_buildEngine.LogMessageEvent(message);
}
}
示例4: RaiseMessageEvent
/// <summary>
/// Raises a message event to all registered loggers.
/// </summary>
/// <owner>SumedhK</owner>
/// <param name="sender"></param>
/// <param name="e"></param>
internal void RaiseMessageEvent(object sender, BuildMessageEventArgs e)
{
if (MessageRaised != null)
{
try
{
MessageRaised(sender, e);
}
catch (LoggerException)
{
// if a logger has failed politely, abort immediately
// first unregister all loggers, since other loggers may receive remaining events in unexpected orderings
// if a fellow logger is throwing in an event handler.
this.UnregisterAllLoggers();
throw;
}
catch (Exception exception)
{
// first unregister all loggers, since other loggers may receive remaining events in unexpected orderings
// if a fellow logger is throwing in an event handler.
this.UnregisterAllLoggers();
InternalLoggerException.Throw(exception, e, "FatalErrorWhileLogging", false);
}
}
RaiseAnyEvent(sender, e);
}
示例5: LogMessageEvent
public void LogMessageEvent(BuildMessageEventArgs e)
{
if (MessageIsImportantEnough(e.Importance))
{
Console.WriteLine(e.Message);
}
}
示例6: VerifyEventType
public void VerifyEventType()
{
BuildFinishedEventArgs buildFinished = new BuildFinishedEventArgs("Message", "Keyword", true);
BuildStartedEventArgs buildStarted = new BuildStartedEventArgs("Message", "Help");
BuildMessageEventArgs lowMessage = new BuildMessageEventArgs("Message", "help", "sender", MessageImportance.Low);
TaskStartedEventArgs taskStarted = new TaskStartedEventArgs("message", "help", "projectFile", "taskFile", "taskName");
TaskFinishedEventArgs taskFinished = new TaskFinishedEventArgs("message", "help", "projectFile", "taskFile", "taskName", true);
TaskCommandLineEventArgs commandLine = new TaskCommandLineEventArgs("commandLine", "taskName", MessageImportance.Low);
BuildWarningEventArgs warning = new BuildWarningEventArgs("SubCategoryForSchemaValidationErrors", "MSB4000", "file", 1, 2, 3, 4, "message", "help", "sender");
BuildErrorEventArgs error = new BuildErrorEventArgs("SubCategoryForSchemaValidationErrors", "MSB4000", "file", 1, 2, 3, 4, "message", "help", "sender");
TargetStartedEventArgs targetStarted = new TargetStartedEventArgs("message", "help", "targetName", "ProjectFile", "targetFile");
TargetFinishedEventArgs targetFinished = new TargetFinishedEventArgs("message", "help", "targetName", "ProjectFile", "targetFile", true);
ProjectStartedEventArgs projectStarted = new ProjectStartedEventArgs(-1, "message", "help", "ProjectFile", "targetNames", null, null, null);
ProjectFinishedEventArgs projectFinished = new ProjectFinishedEventArgs("message", "help", "ProjectFile", true);
ExternalProjectStartedEventArgs externalStartedEvent = new ExternalProjectStartedEventArgs("message", "help", "senderName", "projectFile", "targetNames");
VerifyLoggingPacket(buildFinished, LoggingEventType.BuildFinishedEvent);
VerifyLoggingPacket(buildStarted, LoggingEventType.BuildStartedEvent);
VerifyLoggingPacket(lowMessage, LoggingEventType.BuildMessageEvent);
VerifyLoggingPacket(taskStarted, LoggingEventType.TaskStartedEvent);
VerifyLoggingPacket(taskFinished, LoggingEventType.TaskFinishedEvent);
VerifyLoggingPacket(commandLine, LoggingEventType.TaskCommandLineEvent);
VerifyLoggingPacket(warning, LoggingEventType.BuildWarningEvent);
VerifyLoggingPacket(error, LoggingEventType.BuildErrorEvent);
VerifyLoggingPacket(targetStarted, LoggingEventType.TargetStartedEvent);
VerifyLoggingPacket(targetFinished, LoggingEventType.TargetFinishedEvent);
VerifyLoggingPacket(projectStarted, LoggingEventType.ProjectStartedEvent);
VerifyLoggingPacket(projectFinished, LoggingEventType.ProjectFinishedEvent);
VerifyLoggingPacket(externalStartedEvent, LoggingEventType.CustomEvent);
}
示例7: Execute
public bool Execute()
{
StreamReader streamreaderAssemblyInfo = null;
Match matchVersion;
Group groupVersion;
string strLine;
strAssemblyFileVersion = String.Empty;
try
{
streamreaderAssemblyInfo = new StreamReader(strFilePathAssemblyInfo);
while ((strLine = streamreaderAssemblyInfo.ReadLine()) != null)
{
matchVersion = Regex.Match(strLine, @"(?:AssemblyFileVersion\("")(?<ver>(\d*)\.(\d*)(\.(\d*)(\.(\d*))?)?)(?:""\))", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline | RegexOptions.ExplicitCapture);
if (matchVersion.Success)
{
groupVersion = matchVersion.Groups["ver"];
if ((groupVersion.Success) && (!String.IsNullOrEmpty(groupVersion.Value)))
{
strAssemblyFileVersion = groupVersion.Value;
break;
}
}
}
}
catch (Exception e)
{
BuildMessageEventArgs args = new BuildMessageEventArgs(e.Message, string.Empty, "GetAssemblyFileVersion", MessageImportance.High);
BuildEngine.LogMessageEvent(args);
}
finally { if (streamreaderAssemblyInfo != null) streamreaderAssemblyInfo.Close(); }
return (true);
}
示例8: AddTaskParameter
/// <summary>
/// Handler for a BuildMessage log event. Adds the node to the appropriate target.
/// </summary>
/// <param name="buildMessageEventArgs">The <see cref="BuildMessageEventArgs"/> instance containing the event data.</param>
/// <param name="messagePrefix">The message prefix.</param>
public void AddTaskParameter(BuildMessageEventArgs buildMessageEventArgs, string messagePrefix)
{
var project = GetOrAddProject(buildMessageEventArgs.BuildEventContext.ProjectContextId);
var target = project.GetTargetById(buildMessageEventArgs.BuildEventContext.TargetId);
var task = target.GetTaskById(buildMessageEventArgs.BuildEventContext.TaskId);
task.AddParameter(TaskParameter.Create(buildMessageEventArgs.Message, messagePrefix));
}
示例9: eventSource_MessageRaised
public void eventSource_MessageRaised(object sender, BuildMessageEventArgs e)
{
if((e.Importance == MessageImportance.High && IsVerbosityAtLeast(LoggerVerbosity.Minimal)) ||
(e.Importance == MessageImportance.Normal && IsVerbosityAtLeast(LoggerVerbosity.Normal)) ||
(e.Importance == MessageImportance.Low && IsVerbosityAtLeast(LoggerVerbosity.Detailed)))
{
WriteMessage(e.Message);
}
}
示例10: eventSource_MessageRaised
void eventSource_MessageRaised(object sender, BuildMessageEventArgs e)
{
if (e.GetType() == typeof(TaskCommandLineEventArgs))
{
TaskCommandLineEventArgs cl = (TaskCommandLineEventArgs)e;
MFuVisionGenerator.EnqueueItem(cl.Message, Directory.GetCurrentDirectory(), this.ProjectBuildContext);
}
}
示例11: TestLogMessageLogsABuildErrorWhenATsLintWarningOccurs
public void TestLogMessageLogsABuildErrorWhenATsLintWarningOccurs()
{
mockBuildEngine.Setup(engine => engine.LogErrorEvent(It.IsAny<BuildErrorEventArgs>()));
mockBuildEngine.Setup(engine => engine.LogMessageEvent(It.IsAny<BuildMessageEventArgs>()));
BuildMessageEventArgs message = new BuildMessageEventArgs(
@"(quotemark) Private\Welcome\Welcome.ts[4, 20]: ' should be """,
string.Empty,
string.Empty,
MessageImportance.High);
TsLintLogAnalyzer.LogMessage(mockBuildEngine.Object, message);
}
示例12: Cancel
/// <summary>
/// Perform Cancel Code
/// </summary>
public void Cancel()
{
try
{
proc.Kill();
}
catch (Exception ex)
{
BuildMessageEventArgs taskEvent2 = new BuildMessageEventArgs(ex.Message, "", "", MessageImportance.High);
BuildEngine.LogMessageEvent(taskEvent2);
}
}
示例13: eventSource_MessageRaised
void eventSource_MessageRaised(object sender, BuildMessageEventArgs e)
{
// BuildMessageEventArgs adds Importance to BuildEventArgs
// Let's take account of the verbosity setting we've been passed in deciding whether to log the message
if ((e.Importance == MessageImportance.High && IsVerbosityAtLeast(LoggerVerbosity.Minimal))
|| (e.Importance == MessageImportance.Normal && IsVerbosityAtLeast(LoggerVerbosity.Normal))
|| (e.Importance == MessageImportance.Low && IsVerbosityAtLeast(LoggerVerbosity.Detailed))
)
{
WriteLineWithSenderAndMessage(String.Empty, e);
}
}
示例14: EventSourceMessageRaised
private void EventSourceMessageRaised(object sender, BuildMessageEventArgs e)
{
// BuildMessageEventArgs adds Importance to BuildEventArgs
// Let's take account of the verbosity setting we've been passed in deciding whether to log the message
if ((e.Importance == MessageImportance.High && _verbosity == LoggerVerbosity.Minimal)
|| (e.Importance == MessageImportance.Normal && _verbosity == LoggerVerbosity.Normal)
|| (e.Importance == MessageImportance.Low && _verbosity == LoggerVerbosity.Detailed)
)
{
WriteMessage(string.Empty, e);
}
}
示例15: AssignmentTest
public void AssignmentTest ()
{
BuildMessageEventArgs bmea;
string message = "message";
string helpKeyword = "helpKeyword";
string senderName = "senderName";
MessageImportance messageImportance = MessageImportance.High;
bmea = new BuildMessageEventArgs (message, helpKeyword, senderName, messageImportance);
Assert.AreEqual (message, bmea.Message, "Message");
Assert.AreEqual (helpKeyword, bmea.HelpKeyword, "HelpKeyword");
Assert.AreEqual (senderName, bmea.SenderName, "SenderName");
Assert.AreEqual (messageImportance, bmea.Importance, "Importance");
}