using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Build.Execution; using Microsoft.Build.Framework; namespace SvnForm { class BuildLogger:ILogger { private IEventSource eventSource; private SvnMain buildSolution; public BuildLogger(SvnMain form) { buildSolution = form; } #region ILogger Members public void Initialize(Microsoft.Build.Framework.IEventSource eventSource) { this.eventSource = eventSource; //eventSource.MessageRaised += new Microsoft.Build.Framework.BuildMessageEventHandler(eventSource_MessageRaised); //eventSource.ProjectStarted += new ProjectStartedEventHandler(eventSource_ProjectStarted); //eventSource.WarningRaised += new BuildWarningEventHandler(eventSource_WarningRaised); //eventSource.ProjectStarted +=new ProjectStartedEventHandler(eventSource_ProjectStarted); //eventSource.ProjectFinished += new ProjectFinishedEventHandler(eventSource_ProjectFinished); eventSource.ErrorRaised += new BuildErrorEventHandler(eventSource_ErrorRaised); //eventSource.StatusEventRaised += new BuildStatusEventHandler(); //eventSource.TargetFinished += new TargetFinishedEventHandler(eventSource_TargetFinished); } void eventSource_MessageRaised(object sender, BuildMessageEventArgs e) { buildSolution.AppendTextToBuildLog("MESSAGE: " + e.Message + Environment.NewLine); } void eventSource_TargetFinished(object sender, TargetFinishedEventArgs e) { buildSolution.AppendTextToBuildLog("MESSAGE: " + e.Message + Environment.NewLine); } void eventSource_ErrorRaised(object sender, BuildErrorEventArgs e) { buildSolution.AppendTextToBuildLog("ERROR: " + e.Message + Environment.NewLine); } public string Parameters { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } void eventSource_WarningRaised(object sender, BuildWarningEventArgs e) { // ProjectStartedEventArgs adds ProjectFile, TargetNames // Just the regular message string is good enough here, so just display that. buildSolution.AppendTextToBuildLog("WARNING: " + e.Message + Environment.NewLine); } void eventSource_ProjectStarted(object sender, ProjectStartedEventArgs e) { buildSolution.AppendTextToBuildLog("Project Started: " + e.ProjectFile + Environment.NewLine); } void eventSource_ProjectFinished(object sender, ProjectFinishedEventArgs e) { // The regular message string is good enough here too. buildSolution.AppendTextToBuildLog("project Finished: " + e.ProjectFile + Environment.NewLine); } public void Shutdown() { eventSource.MessageRaised -= new Microsoft.Build.Framework.BuildMessageEventHandler(eventSource_MessageRaised); } //public bool IsVerbosityAtLeast(LoggerVerbosity checkVerbosity); public LoggerVerbosity Verbosity { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } #endregion } }