示例#1
0
        private static string GetUnitName(BuildScope buildScope)
        {
            string unitName = "";

            switch (buildScope)
            {
            case BuildScope.Solution:
                unitName = Resources.BuildScopeSolution_UnitName;
                //if (_labelSettings.ShowSolutionName)
                //unitName += string.Format(Resources.BuildScopeSolution_SolutionNameTemplate, solutionItem.Name);
                break;

            case BuildScope.Batch:
                unitName = Resources.BuildScopeBatch_UnitName;
                break;

            case BuildScope.Project:
                unitName = Resources.BuildScopeProject_UnitName;
                // TODO specify name for project?
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(buildScope));
            }

            return(unitName);
        }
示例#2
0
        public void BuildStarted(BuildAction buildAction, BuildScope buildScope)
        {
            _currentQueuePosOfBuildingProject          = 0;
            ErrorNavigationService.BuildErrorNavigated = false;
            _buildOutputLogger.Attach();

            ResetBuildInformationModel();
            ReloadCurrentProjects();

            BuildInformationModel.BuildStartTime    = DateTime.Now;
            BuildInformationModel.BuildFinishTime   = null;
            BuildInformationModel.CurrentBuildState = BuildState.InProgress;
            BuildInformationModel.BuildAction       = buildAction;
            BuildInformationModel.BuildScope        = buildScope;
            BuildInformationModel.BuildId           = Guid.NewGuid();

            _windowStateService.ApplyToolWindowStateAction(_packageSettingsProvider.Settings.WindowSettings.WindowActionOnBuildBegin);
            _timer = new Timer(state => BuildUpdate(), null, BuildInProcessQuantumSleep, BuildInProcessQuantumSleep);

            string message = _buildMessagesFactory.GetBuildBeginMajorMessage(BuildInformationModel);

            _statusBarNotificationService.ShowTextWithFreeze(message);
            _origTextCurrentState = message;
            BuildInformationModel.StateMessage = _origTextCurrentState;
            UpdateTaskBar();
            BuildStateChanged();

            DiagnosticsClient.TrackEvent("BuildStarted", new Dictionary <string, string>
            {
                { "BuildId", BuildInformationModel.BuildId.ToString() },
                { "BuildAction", buildAction.ToString() },
                { "BuildScope", buildScope.ToString() }
            });
        }
示例#3
0
    public static bool Build(Arguments arguments)
    {
        var pipeline = new MarkdownPipelineBuilder()
                       .UseAdvancedExtensions()
                       .UsePrism()
                       .Build();

        Site site = new(arguments.TroubleshooterRoot);

        using var buildScope = new BuildScope(arguments);
        try
        {
            BuildPages(arguments, site, pipeline);
            BuildContent(arguments, site);
        }
        catch (BuildException e)
        {
            Console.WriteLine();
            Console.WriteLine(e);
            buildScope.MarkBuildAsFailed();
            return(false);
        }

        return(true);
    }
示例#4
0
        public void UpdateTaskBarInfo(BuildState buildState, BuildScope buildScope, int projectsCount, int finishedProjects)
        {
            if (_resetTaskBarInfoCts != null && !_resetTaskBarInfoCts.IsCancellationRequested)
            {
                _resetTaskBarInfoCts.Cancel();
            }

            if (!_packageSettingsProvider.Settings.GeneralSettings.BuildProgressSettings.TaskBarProgressEnabled)
            {
                return;
            }

            _taskbarItemInfo.Value.ProgressState = buildState.ToTaskBarItemProgressState(buildScope);

            if (projectsCount <= 0)
            {
                _taskbarItemInfo.Value.ProgressValue = 0;
            }
            else if (projectsCount == finishedProjects)
            {
                _taskbarItemInfo.Value.ProgressValue = 1;
            }
            else
            {
                var incProgressValue = 1.0 / (projectsCount * 2.0);
                _taskbarItemInfo.Value.ProgressValue = incProgressValue * finishedProjects;
            }

            if (buildState == BuildState.Done || buildState == BuildState.ErrorDone || buildState == BuildState.Failed || buildState == BuildState.Cancelled)
            {
                ResetTaskBarInfoOnBuildDone();
            }
        }
        /// <summary>
        /// Executes the Categorization task
        /// The primary objective is to do the following:
        /// 1) Find supported/unsupported TargetFramework specified in the project file
        /// 2) Categorize if a project is a test project or not (currently we rely on references added to the project to decide if a project is Test or not)
        /// At the end of this task we get 6 outputs
        /// Each output array is a list of project categorized according to the TargetFramework the project is targeting.
        /// </summary>
        /// <returns></returns>
        public override bool Execute()
        {
            List <string> sdkProjects    = new List <string>();
            List <string> testProjects   = new List <string>();
            List <string> allProjects    = new List <string>();
            List <string> ignorePathList = new List <string>();

            string[] ignoreTokens = IgnoreDirNameForSearchingProjects.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string igTkn in ignoreTokens)
            {
                ignorePathList.Add(igTkn);
            }

            if (!ignorePathList.Contains(KV_IGNOREDIRNAME))
            {
                ignorePathList.Add(KV_IGNOREDIRNAME);
            }
            ProjectSearchUtility ProjUtil = new ProjectSearchUtility(SourceRootDirPath, ignorePathList);

            if (BuildScope.Equals("All", StringComparison.OrdinalIgnoreCase))
            {
                sdkProjects  = ProjUtil.GetAllSDKProjects();
                testProjects = ProjUtil.GetFilteredTestProjects();
            }
            else //We set default scope to All if empty/null, so safe to evaluate to Else in this case
            {
                sdkProjects  = ProjUtil.GetScopedSDKProjects(BuildScope);
                testProjects = ProjUtil.GetScopedTestProjects(BuildScope);
            }

            allProjects.AddRange(sdkProjects);
            allProjects.AddRange(testProjects);

            ConcurrentBag <SdkProjectMetaData> projWithMetaData = new ConcurrentBag <SdkProjectMetaData>();

            var projTimeBefore = DateTime.Now;

            projWithMetaData = GetProjectData(allProjects, projWithMetaData);
            var projTimeAfter = DateTime.Now;

            Debug.WriteLine("Parsing Projects took {0}", (projTimeAfter - projTimeBefore).TotalSeconds.ToString());

            var net452SdkProjects     = from s in projWithMetaData where (s.IsTargetFxSupported == true && s.FxMoniker == TargetFrameworkMoniker.net452 && s.ProjectType == SdkProjctType.Sdk) select s.ProjectTaskItem;
            var netStd14SdkProjects   = from s in projWithMetaData where (s.IsTargetFxSupported == true && s.FxMoniker == TargetFrameworkMoniker.netstandard14 && s.ProjectType == SdkProjctType.Sdk) select s.ProjectTaskItem;
            var netCore11SdkProjects  = from s in projWithMetaData where (s.IsTargetFxSupported == true && s.FxMoniker == TargetFrameworkMoniker.netcoreapp11 && s.ProjectType == SdkProjctType.Sdk) select s.ProjectTaskItem;
            var testNetCore11Projects = from s in projWithMetaData where (s.IsTargetFxSupported == true && s.FxMoniker == TargetFrameworkMoniker.netcoreapp11 && s.ProjectType == SdkProjctType.Test) select s.ProjectTaskItem;
            var testNet452Projects    = from s in projWithMetaData where (s.IsTargetFxSupported == true && s.FxMoniker == TargetFrameworkMoniker.net452 && s.ProjectType == SdkProjctType.Test) select s.ProjectTaskItem;
            var unSupportedProjects   = from s in projWithMetaData where (s.IsTargetFxSupported == false) select s.ProjectTaskItem;

            net452SdkProjectsToBuild     = net452SdkProjects?.ToArray <ITaskItem>();
            netStd14SdkProjectsToBuild   = netStd14SdkProjects?.ToArray <ITaskItem>();
            netCore11SdkProjectsToBuild  = netCore11SdkProjects?.ToArray <ITaskItem>();
            netCore11TestProjectsToBuild = testNetCore11Projects?.ToArray <ITaskItem>();
            net452TestProjectsToBuild    = testNet452Projects?.ToArray <ITaskItem>();
            unSupportedProjectsToBuild   = unSupportedProjects?.ToArray <ITaskItem>();

            return(true);
        }
示例#6
0
        List <string> GetProjectsToBeSkiped()
        {
            string notSupportedErrorFormat = @"Unable to execute skipping tests on following directory '{0}'";

            List <string> ScopedProjects = new List <string>();

            // We will not skip broad build scope (e.g. sdk), the idea is to not to skip all the tests in a broader build scope.
            if (BuildScope.Equals("sdk", StringComparison.OrdinalIgnoreCase))
            {
                TaskLogger.LogException <NotSupportedException>(notSupportedErrorFormat, BuildScope);
            }
            else if (BuildScopes.Equals("sdk", StringComparison.OrdinalIgnoreCase))
            {
                TaskLogger.LogException <NotSupportedException>(notSupportedErrorFormat, BuildScope);
            }
            else
            {
                string sdkRootDirPath = Path.Combine(RepositoryRootDirPath, "sdk");

                CategorizeSDKProjectsTask catProj = new CategorizeSDKProjectsTask(RepositoryRootDirPath, BuildScope, null, ProjectType, ProjectCategory);
                catProj.BuildScopes = BuildScopes;
                catProj.Execute();

                if (catProj.MultipleScopes.Contains("sdk"))
                {
                    TaskLogger.LogException <NotSupportedException>(notSupportedErrorFormat, sdkRootDirPath);
                }
                else
                {
                    var sdkProj  = catProj.SDK_Projects.Select <SDKMSBTaskItem, string>((item) => item.ItemSpec);
                    var testProj = catProj.Test_Projects.Select <SDKMSBTaskItem, string>((item) => item.ItemSpec);

                    if (sdkProj.NotNullOrAny <string>())
                    {
                        ScopedProjects.AddRange(sdkProj.ToList <string>());
                    }

                    if (testProj.NotNullOrAny <string>())
                    {
                        ScopedProjects.AddRange(testProj.ToList <string>());
                    }
                }
            }

            return(ScopedProjects);
        }
        public override bool Execute()
        {
            base.Execute();
            if (WhatIf)
            {
                WhatIfAction();
            }
            else
            {
                List <string> ScopedProjects = new List <string>();

                // We will not skip broad build scope (e.g. sdk), the idea is to not to skip all the tests in a broader build scope.
                if (string.IsNullOrWhiteSpace(BuildScope))
                {
                    TaskLogger.LogWarning("BuildScope is required to skip tests.");
                }
                else if (BuildScope.Equals("sdk", StringComparison.OrdinalIgnoreCase))
                {
                    TaskLogger.LogWarning("'{0}' BuildScope is not supported", BuildScope);
                }
                else
                {
                    CategorizeSDKProjectsTask catProj = new CategorizeSDKProjectsTask(RepositoryRootDirPath, BuildScope, BuildScopes, ProjectType, ProjectCategory);
                    catProj.Execute();

                    var sdkProj  = catProj.SDK_Projects.Select <SDKMSBTaskItem, string>((item) => item.ItemSpec);
                    var testProj = catProj.Test_Projects.Select <SDKMSBTaskItem, string>((item) => item.ItemSpec);

                    if (sdkProj.NotNullOrAny <string>())
                    {
                        ScopedProjects.AddRange(sdkProj.ToList <string>());
                    }

                    if (testProj.NotNullOrAny <string>())
                    {
                        ScopedProjects.AddRange(testProj.ToList <string>());
                    }

                    UpdateProjects(ScopedProjects);
                    ScopedProjects.Clear();
                }
            }

            return(TaskLogger.TaskSucceededWithNoErrorsLogged);
        }
        protected override void WhatIfAction()
        {
            TaskLogger.LogInfo(MessageImportance.High, "Projects will be categorized for Scope '{0}'", BuildScope.ToString());
            TaskLogger.LogInfo(MessageImportance.High, "Project Type '{0}' will be used ", ProjType.ToString());
            TaskLogger.LogInfo(MessageImportance.High, "Project Category '{0}' will be used ", ProjCat.ToString());
            TaskLogger.LogInfo(MessageImportance.High, "Tokens to be included '{0}'", CmdLineIncludeScope);
            TaskLogger.LogInfo(MessageImportance.High, "Tokens to be excluded '{0}'", CmdLineExcludeScope);

            TaskLogger.LogInfo(MessageImportance.High, "Repository Root Dir Path '{0}'", RepositoryRootDirPath);

            ProjectSearchUtility psu = new ProjectSearchUtility(RepositoryRootDirPath, MultipleScopes, BuildScope, FullyQualifiedBuildScopeDirPath, CmdLineExcludeScope, CmdLineIncludeScope, ProjType, ProjCat);

            psu.UseLegacyDirs = UseLegacyDirStructure;
            TaskLogger.LogInfo(MessageImportance.High, "Use Legacy Directory Strucuture is set to '{0}'", psu.UseLegacyDirs.ToString());
            TaskLogger.LogInfo(MessageImportance.High, "SDK Root Dir Path '{0}'", psu.SDKRootDir);
            TaskLogger.LogInfo(MessageImportance.High, psu.SearchDirPaths, "Search Dir Path(s)");
        }
示例#9
0
        public static TaskbarItemProgressState ToTaskBarItemProgressState(this BuildState buildState, BuildScope buildScope)
        {
            var progressState = TaskbarItemProgressState.Normal;

            if (buildState == BuildState.Cancelled)
            {
                progressState = TaskbarItemProgressState.Paused;
            }
            else if (buildState == BuildState.Failed)
            {
                progressState = TaskbarItemProgressState.Error;
            }
            else if (buildState != BuildState.InProgress)
            {
                progressState = TaskbarItemProgressState.None;
            }
            else if (buildScope != BuildScope.Solution)
            {
                progressState = TaskbarItemProgressState.Indeterminate;
            }
            else
            {
                progressState = TaskbarItemProgressState.Normal;
            }

            return(progressState);
        }