/// <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); }
public void GetMgmtProjects() { string scopeToken = "compute"; ProjectSearchUtility psu = new ProjectSearchUtility(this.TestAssetSdkForNetDirPath, null, scopeToken, string.Empty, string.Empty, string.Empty, SdkProjectType.All, SdkProjectCategory.MgmtPlane); List<string> sdkProj = psu.Find_Mgmt_SDKProjects(); Assert.Single(sdkProj); List<string> testProj = psu.Find_Mgmt_TestProjects(); Assert.Single(testProj); }
public void SkipTestExecutionForOneProjects() { ProjectSearchUtility psu = new ProjectSearchUtility(rootDir); List <string> scopeDirs = psu.FindTopLevelScopes(returnPartialScopePaths: true); Assert.NotEmpty(scopeDirs); SkipBuildOrTestExecutionTask ste = new SkipBuildOrTestExecutionTask(rootDir); ste.BuildScope = @"Advisor"; ste.SkipFromTestExecution = true; ste.ProjectType = "Test"; Assert.True(ste.Execute()); }
public void SkipTestExecutionForAllProjects() { ProjectSearchUtility psu = new ProjectSearchUtility(rootDir); List <string> scopeDirs = psu.FindTopLevelScopes(returnPartialScopePaths: true); Assert.NotEmpty(scopeDirs); foreach (string relativeScopePath in scopeDirs) { SkipTestExecutionTask ste = new SkipTestExecutionTask(rootDir); ste.BuildScope = relativeScopePath; ste.ExcludeFromTestExecution = true; ste.ProjectType = "Test"; Assert.True(ste.Execute()); } }
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)"); }
/// <summary> /// /// </summary> void Categorize() { TaskLogger.LogInfo("Categorizing Projects....."); List <SdkProjectMetadata> sdkProjList = new List <SdkProjectMetadata>(); List <SdkProjectMetadata> testProjList = new List <SdkProjectMetadata>(); List <SdkProjectMetadata> unsupportedProjList = new List <SdkProjectMetadata>(); List <SdkProjectMetadata> testToBeRunProjList = new List <SdkProjectMetadata>(); List <SdkProjectMetadata> platformSpecificSkippedProjList = new List <SdkProjectMetadata>(); List <string> searchedProjects = new List <string>(); ProjectSearchUtility psu = null; Dictionary <string, SdkProjectMetadata> allProj = null; psu = new ProjectSearchUtility(RepositoryRootDirPath, MultipleScopes, BuildScope, FullyQualifiedBuildScopeDirPath, CmdLineExcludeScope, CmdLineIncludeScope, ProjType, ProjCat); psu.UseLegacyDirs = UseLegacyDirStructure; searchedProjects = psu.FindProjects(); allProj = LoadProjectData(searchedProjects); foreach (KeyValuePair <string, SdkProjectMetadata> kv in allProj) { SdkProjectMetadata pmd = kv.Value; switch (pmd.ProjectType) { #region SDK case SdkProjectType.Sdk: { if (!pmd.Fx.IsTargetFxMatch) { if (!pmd.Fx.IsApplicableForCurrentPlatform) { platformSpecificSkippedProjList.Add(pmd); } else { unsupportedProjList.Add(pmd); } } else if (!pmd.Fx.IsApplicableForCurrentPlatform) { platformSpecificSkippedProjList.Add(pmd); } else { if (!pmd.ExcludeFromBuild) { sdkProjList.Add(pmd); } } break; } #endregion #region Test case SdkProjectType.Test: { // WE HAVE INTENTIONALLY SKIPPED CHECKING THIS PROPERTY, BASICALLY WE WILL NOT BE VERIFYING BASELINE TARGETFX FOR TEST PROJECTS // IF WE EVER DECIDE TO DO IT, SIMPLY ENABLE THE BELOW CODE // if (!pmd.Fx.IsTargetFxMatch) // { // if (!pmd.Fx.IsApplicableForCurrentPlatform) // { // platformSpecificSkippedProjList.Add(pmd); // } // else // { // unsupportedProjList.Add(pmd); // } // } if (!pmd.Fx.IsApplicableForCurrentPlatform) { platformSpecificSkippedProjList.Add(pmd); } else { if (!pmd.ExcludeFromBuild) { testProjList.Add(pmd); } if (!pmd.ExcludeFromTest) { testToBeRunProjList.Add(pmd); } } break; } #endregion } } SDK_Projects = sdkProjList.Select <SdkProjectMetadata, SDKMSBTaskItem>((item) => new SDKMSBTaskItem(item)).ToArray <SDKMSBTaskItem>(); Test_Projects = testProjList.Select <SdkProjectMetadata, SDKMSBTaskItem>((item) => new SDKMSBTaskItem(item)).ToArray <SDKMSBTaskItem>(); UnSupportedProjects = unsupportedProjList.Select <SdkProjectMetadata, SDKMSBTaskItem>((item) => new SDKMSBTaskItem(item)).ToArray <SDKMSBTaskItem>(); Test_ToBe_Run = testToBeRunProjList.Select <SdkProjectMetadata, SDKMSBTaskItem>((item) => new SDKMSBTaskItem(item)).ToArray <SDKMSBTaskItem>(); PlatformSpecificSkippedProjects = platformSpecificSkippedProjList.Select <SdkProjectMetadata, SDKMSBTaskItem>((item) => new SDKMSBTaskItem(item)).ToArray <SDKMSBTaskItem>(); SdkPkgReferenceList = GetNormalizedPkgRefList(); TaskLogger.LogInfo("SDK Project(s) found:'{0}'", SDK_Projects.Count().ToString()); TaskLogger.LogInfo(MessageImportance.Low, SDK_Projects, "File Paths for SDK Projects"); TaskLogger.LogInfo("Test Project(s) found:'{0}'", Test_Projects.Count().ToString()); TaskLogger.LogInfo(MessageImportance.Low, Test_Projects, "File Paths for Test Projects"); TaskLogger.LogInfo("Test Project(s) whose tests will be executed are:'{0}'", Test_ToBe_Run.Count().ToString()); TaskLogger.LogInfo(MessageImportance.Low, Test_ToBe_Run, "File Paths for Test Projects whose tests will be executed"); if (UnSupportedProjects.NotNullOrAny <SDKMSBTaskItem>()) { TaskLogger.LogInfo("Project(s) whose target framework is not currently supported:'{0}'", UnSupportedProjects.Count().ToString()); TaskLogger.LogInfo(MessageImportance.Low, UnSupportedProjects, "File Paths for Unsupported Projects"); } //if (Test_ToBe_Run.NotNullOrAny<SDKMSBTaskItem>()) //{ // TaskLogger.LogInfo("Test Project(s) whose tests will be executed are:'{0}'", Test_ToBe_Run.Count().ToString()); // TaskLogger.LogInfo(MessageImportance.Low, Test_ToBe_Run, "File Paths for Test Projects whose tests will be executed"); //} if (PlatformSpecificSkippedProjects.NotNullOrAny <SDKMSBTaskItem>()) { TaskLogger.LogInfo("Test Project(s) that will be skipped from building/executing tests are:'{0}'", PlatformSpecificSkippedProjects.Count().ToString()); TaskLogger.LogInfo(MessageImportance.Low, PlatformSpecificSkippedProjects, "File Paths for Projects that will be skipped that are platform specific"); } if (SdkPkgReferenceList != null) { TaskLogger.LogInfo("PackageReferences count:'{0}'", SdkPkgReferenceList.Count().ToString()); TaskLogger.LogInfo(MessageImportance.Low, SdkPkgReferenceList, "Packages References"); } }
public ProjectSearchTests() { RepoRootDirPath = @"D:\adxRepo\netSdk\master"; ProjSearch = new ProjectSearchUtility(this.TestAssetSdkForNetDirPath); }