Esempio n. 1
0
        private void BuildOutputLogger_OnErrorRaised(BuildProjectContextEntry projectEntry, object e, ErrorLevel errorLevel)
        {
            try
            {
                var projectItem = projectEntry.ProjectItem;
                if (projectItem == null)
                {
                    if (!TryGetProjectItem(projectEntry, out projectItem))
                    {
                        projectEntry.IsInvalid = true;
                        return;
                    }
                }

                var errorItem = new ErrorItem(errorLevel);
                switch (errorLevel)
                {
                case ErrorLevel.Message:
                    errorItem.Init((BuildMessageEventArgs)e);
                    break;

                case ErrorLevel.Warning:
                    errorItem.Init((BuildWarningEventArgs)e);
                    break;

                case ErrorLevel.Error:
                    errorItem.Init((BuildErrorEventArgs)e);
                    break;

                default:
                    break;
                }

                errorItem.VerifyValues();
                projectItem.AddErrorItem(errorItem);

                var  args            = new BuildErrorRaisedEventArgs(errorLevel, projectItem);
                bool buildNeedCancel = (args.ErrorLevel == ErrorLevel.Error && _packageSettingsProvider.Settings.GeneralSettings.StopBuildAfterFirstError);
                if (buildNeedCancel)
                {
                    _buildService.CancelBuildSolution();
                }

                bool navigateToBuildFailure = (args.ErrorLevel == ErrorLevel.Error && _packageSettingsProvider.Settings.GeneralSettings.NavigateToBuildFailureReason == NavigateToBuildFailureReasonCondition.OnErrorRaised);
                if (navigateToBuildFailure && !ErrorNavigationService.BuildErrorNavigated)
                {
                    _errorNavigationService.NavigateToErrorItem(errorItem);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Failed to fetch errormessage.");
            }
        }