Fix project selection based on directory (#2087)

This commit is contained in:
Paulo Janotti 2023-01-26 18:08:23 -08:00 committed by GitHub
parent 277d778b3d
commit a2a50f5366
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 6 deletions

View File

@ -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<Project> 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 class ProjectsHelper
.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 class ProjectsHelper
.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