コード例 #1
0
        public EventProcessor(string projectFilePath, IEnumerable <ILogger> loggers, IEventSource eventSource, bool analyze)
        {
            _projectFilePath = projectFilePath;
            _loggers         = loggers;

            // Initialize the loggers
            foreach (ILogger logger in loggers)
            {
                logger.Initialize(eventSource);
            }

            // Send events to the tree constructor
            if (analyze)
            {
                _construction                  = new Microsoft.Build.Logging.StructuredLogger.Construction();
                eventSource.BuildStarted      += _construction.BuildStarted;
                eventSource.BuildFinished     += _construction.BuildFinished;
                eventSource.ProjectStarted    += _construction.ProjectStarted;
                eventSource.ProjectFinished   += _construction.ProjectFinished;
                eventSource.TargetStarted     += _construction.TargetStarted;
                eventSource.TargetFinished    += _construction.TargetFinished;
                eventSource.TaskStarted       += _construction.TaskStarted;
                eventSource.TaskFinished      += _construction.TaskFinished;
                eventSource.MessageRaised     += _construction.MessageRaised;
                eventSource.WarningRaised     += _construction.WarningRaised;
                eventSource.ErrorRaised       += _construction.ErrorRaised;
                eventSource.CustomEventRaised += _construction.CustomEventRaised;
                eventSource.StatusEventRaised += _construction.StatusEventRaised;
            }
        }
コード例 #2
0
 internal AnalyzerResult(
     ProjectAnalyzer analyzer,
     Microsoft.Build.Logging.StructuredLogger.Construction construction,
     TreeNode tree)
 {
     Analyzer      = analyzer;
     _construction = construction;
     _tree         = tree;
 }
コード例 #3
0
        /// <summary>
        /// Initializes the logger and subscribes to the relevant events.
        /// </summary>
        /// <param name="eventSource">The available events that processEvent logger can subscribe to.</param>
        public override void Initialize(IEventSource eventSource)
        {
            Environment.SetEnvironmentVariable("MSBUILDTARGETOUTPUTLOGGING", "true");
            Environment.SetEnvironmentVariable("MSBUILDLOGIMPORTS", "1");

            // Set this environment variable to log AssemblyFoldersEx search results from ResolveAssemblyReference
            // Environment.SetEnvironmentVariable("MSBUILDLOGVERBOSERARSEARCHRESULTS", "true");

            ProcessParameters();

            if (SaveLogToDisk)
            {
                try
                {
                    projectImportsCollector = new ProjectImportsCollector(_logFile);
                }
                catch (Exception ex)
                {
                    throw new LoggerException($"Failed to create the source archive for log file {_logFile}", ex);
                }
            }

            construction = new Construction();

            eventSource.BuildStarted      += construction.BuildStarted;
            eventSource.BuildFinished     += construction.BuildFinished;
            eventSource.ProjectStarted    += construction.ProjectStarted;
            eventSource.ProjectFinished   += construction.ProjectFinished;
            eventSource.TargetStarted     += construction.TargetStarted;
            eventSource.TargetFinished    += construction.TargetFinished;
            eventSource.TaskStarted       += construction.TaskStarted;
            eventSource.TaskFinished      += construction.TaskFinished;
            eventSource.MessageRaised     += construction.MessageRaised;
            eventSource.WarningRaised     += construction.WarningRaised;
            eventSource.ErrorRaised       += construction.ErrorRaised;
            eventSource.CustomEventRaised += construction.CustomEventRaised;
            eventSource.StatusEventRaised += construction.StatusEventRaised;

            if (projectImportsCollector != null)
            {
                eventSource.AnyEventRaised += EventSource_AnyEventRaised;
            }

            projectImportedEventArgsType = typeof(BuildEventArgs)
                                           .GetTypeInfo()
                                           .Assembly
                                           .GetType("Microsoft.Build.Framework.ProjectImportedEventArgs");
            if (projectImportedEventArgsType != null)
            {
                importedProjectFile = projectImportedEventArgsType.GetProperty("ImportedProjectFile", BindingFlags.Public | BindingFlags.Instance);
                unexpandedProject   = projectImportedEventArgsType.GetProperty("UnexpandedProject", BindingFlags.Public | BindingFlags.Instance);
            }
        }
コード例 #4
0
        private void AddItems(IEnumerable items, TreeNode parent)
        {
            if (items is ICollection collection)
            {
                parent.EnsureChildrenCapacity(collection.Count);
            }

            foreach (ITaskItem item in items)
            {
                var itemNode = new Item {
                    Text = item.ItemSpec
                };
                Construction.AddMetadata(item, itemNode);
                parent.AddChild(itemNode);
            }
        }
コード例 #5
0
        /// <summary>
        /// Initializes the logger and subscribes to the relevant events.
        /// </summary>
        /// <param name="eventSource">The available events that processEvent logger can subscribe to.</param>
        public override void Initialize(IEventSource eventSource)
        {
            Environment.SetEnvironmentVariable("MSBUILDTARGETOUTPUTLOGGING", "true");
            Environment.SetEnvironmentVariable("MSBUILDLOGIMPORTS", "1");

            // Set this environment variable to log AssemblyFoldersEx search results from ResolveAssemblyReference
            // Environment.SetEnvironmentVariable("MSBUILDLOGVERBOSERARSEARCHRESULTS", "true");

            ProcessParameters();

            if (SaveLogToDisk)
            {
                try
                {
                    projectImportsCollector = new ProjectImportsCollector(_logFile);
                }
                catch (Exception ex)
                {
                    throw new LoggerException($"Failed to create the source archive for log file {_logFile}", ex);
                }
            }

            construction = new Construction();

            Strings.Initialize();

            eventSource.BuildStarted      += construction.BuildStarted;
            eventSource.BuildFinished     += construction.BuildFinished;
            eventSource.ProjectStarted    += construction.ProjectStarted;
            eventSource.ProjectFinished   += construction.ProjectFinished;
            eventSource.TargetStarted     += construction.TargetStarted;
            eventSource.TargetFinished    += construction.TargetFinished;
            eventSource.TaskStarted       += construction.TaskStarted;
            eventSource.TaskFinished      += construction.TaskFinished;
            eventSource.MessageRaised     += construction.MessageRaised;
            eventSource.WarningRaised     += construction.WarningRaised;
            eventSource.ErrorRaised       += construction.ErrorRaised;
            eventSource.CustomEventRaised += construction.CustomEventRaised;
            eventSource.StatusEventRaised += construction.StatusEventRaised;

            if (projectImportsCollector != null)
            {
                eventSource.AnyEventRaised += EventSource_AnyEventRaised;
            }
        }
コード例 #6
0
        /// <summary>
        /// Initializes the logger and subscribes to the relevant events.
        /// </summary>
        /// <param name="eventSource">The available events that processEvent logger can subscribe to.</param>
        public override void Initialize(IEventSource eventSource)
        {
            Environment.SetEnvironmentVariable("MSBUILDTARGETOUTPUTLOGGING", "true");

            ProcessParameters();

            construction            = new Construction();
            construction.Completed += Construction_Completed;

            eventSource.BuildStarted      += construction.BuildStarted;
            eventSource.BuildFinished     += construction.BuildFinished;
            eventSource.ProjectStarted    += construction.ProjectStarted;
            eventSource.ProjectFinished   += construction.ProjectFinished;
            eventSource.TargetStarted     += construction.TargetStarted;
            eventSource.TargetFinished    += construction.TargetFinished;
            eventSource.TaskStarted       += construction.TaskStarted;
            eventSource.TaskFinished      += construction.TaskFinished;
            eventSource.MessageRaised     += construction.MessageRaised;
            eventSource.WarningRaised     += construction.WarningRaised;
            eventSource.ErrorRaised       += construction.ErrorRaised;
            eventSource.CustomEventRaised += construction.CustomEventRaised;
        }
コード例 #7
0
 public MessageProcessor(Construction construction, StringCache stringTable)
 {
     this.construction = construction;
     this.stringTable  = stringTable;
 }