Skip to content

Commit

Permalink
Fix project selection based on directory (#2087)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjanotti authored Jan 27, 2023
1 parent 277d778 commit a2a50f5
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions build/ProjectsHelper.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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));
}
Expand All @@ -30,7 +32,7 @@ public static IEnumerable<Project> 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));
}
Expand All @@ -47,7 +49,7 @@ public static IEnumerable<Project> 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
Expand Down

0 comments on commit a2a50f5

Please sign in to comment.