From a2a50f5366e171f5f54e76cf1c015a6115523c43 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Thu, 26 Jan 2023 18:08:23 -0800 Subject: [PATCH] Fix project selection based on directory (#2087) --- build/ProjectsHelper.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/build/ProjectsHelper.cs b/build/ProjectsHelper.cs index cd3bbc10f7..c576bd30ac 100644 --- a/build/ProjectsHelper.cs +++ b/build/ProjectsHelper.cs @@ -1,10 +1,9 @@ +using Nuke.Common; +using Nuke.Common.IO; using Nuke.Common.ProjectModel; public static class ProjectsHelper { - private const string SrcDirName = "src"; - private const string TestDirName = "test"; - private const string NativeProjectMarker = "Native"; // Contains word Native private const string TestsProjectMarker = "Tests"; // Ends with word Tests private const string NetFrameworkMarker = ".NetFramework"; // Ends with word .NetFramework @@ -13,13 +12,16 @@ public static class ProjectsHelper private const string TestApplicationSelector = "TestApplication.*"; private const string TestLibrarySelector = "TestLibrary.*"; + private readonly static AbsolutePath SrcDirectory = NukeBuild.RootDirectory / "src"; + private readonly static AbsolutePath TestDirectory = NukeBuild.RootDirectory / "test"; + public static IEnumerable GetManagedSrcProjects(this Solution solution) { return solution .GetProjects(CoreProjectSelector) .Where(x => // Should contain in the src directory - x.Directory.ToString().Contains(SrcDirName) && + SrcDirectory.Contains(x.Directory) && // Should not be native projects !x.Name.Contains(NativeProjectMarker)); } @@ -30,7 +32,7 @@ public static IEnumerable GetNativeSrcProjects(this Solution solution) .GetProjects(CoreProjectSelector) .Where(x => // Should contain in the src directory - x.Directory.ToString().Contains(SrcDirName) && + SrcDirectory.Contains(x.Directory) && // Should be native projects x.Name.Contains(NativeProjectMarker)); } @@ -47,7 +49,7 @@ public static IEnumerable GetManagedUnitTestProjects(this Solution solu .GetProjects(CoreProjectSelector) .Where(x => // Should contain in the test directory - x.Directory.ToString().Contains(TestDirName) && + TestDirectory.Contains(x.Directory) && // Should not be native projects !x.Name.Contains(NativeProjectMarker) && // Should be test projects