当前位置: 首页>>代码示例>>C#>>正文


C# Framework.BuildMessageEventArgs类代码示例

本文整理汇总了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);
        }
开发者ID:ChronosWS,项目名称:msbuild,代码行数:26,代码来源:LoggingServicesLogMethod_Tests.cs

示例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);
 }
开发者ID:baseclass,项目名称:Contrib.Nuget,代码行数:7,代码来源:ITaskExtensions.cs

示例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);
            }
        }
开发者ID:JeremyKuhne,项目名称:XTask,代码行数:33,代码来源:BuildLogger.cs

示例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);
        }
开发者ID:nikson,项目名称:msbuild,代码行数:33,代码来源:EventSource.cs

示例5: LogMessageEvent

		public void LogMessageEvent(BuildMessageEventArgs e)
		{
			if (MessageIsImportantEnough(e.Importance))
			{
				Console.WriteLine(e.Message);
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:7,代码来源:StubBuildEngine.cs

示例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);
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:30,代码来源:NodePackets_Tests.cs

示例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);
 }
开发者ID:RebelCMS,项目名称:rebelcmsxu5,代码行数:32,代码来源:GetAssemblyFileVersion.cs

示例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));
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:13,代码来源:Build.cs

示例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);
            }
        }
开发者ID:alux-xu,项目名称:ice-builder-visualstudio,代码行数:9,代码来源:BuildLogger.cs

示例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);
            }
        }
开发者ID:AlexandrSurkov,项目名称:PKStudio,代码行数:9,代码来源:MessagesCollector.cs

示例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);
 }
开发者ID:mbraude,项目名称:NCapsulateExtensions.TsLint,代码行数:11,代码来源:TsLintLogAnalyzerTests.cs

示例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);
     }
 }
开发者ID:hkopparru,项目名称:VSPlugin,代码行数:15,代码来源:MakeAllAndFormatOutputMessages.cs

示例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);
     }
 }
开发者ID:twistedtwig,项目名称:NHibernateRepository,代码行数:12,代码来源:MsBuildLogger.cs

示例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);
     }
 }
开发者ID:BackupTheBerlios,项目名称:nantgui,代码行数:12,代码来源:GuiLogger.cs

示例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");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:15,代码来源:BuildMessageEventArgsTest.cs


注:本文中的Microsoft.Build.Framework.BuildMessageEventArgs类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。