forked from chuongmep/CadPythonShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuilderExtensions.cs
More file actions
34 lines (29 loc) · 1.51 KB
/
BuilderExtensions.cs
File metadata and controls
34 lines (29 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
using System.Text.RegularExpressions;
internal static class BuilderExtensions
{
public static Project GetProject(this Solution solution, string projectName) =>
solution.GetProject(projectName) ?? throw new NullReferenceException($"Cannon find project \"{projectName}\"");
public static AbsolutePath GetBinDirectory(this Project project) => project.Directory / "bin";
private static AbsolutePath GetExePath(this Project project, string configuration) => project.GetBinDirectory() / configuration / $"{project.Name}.exe";
public static AbsolutePath GetExecutableFile(this Project project, IEnumerable<string> configurations, List<DirectoryInfo> directories)
{
Console.WriteLine("Start get executable file");
var directory = directories[0].Name;
Console.WriteLine($"executable directory :{directory} ");
var subConfigRegex = new Regex(@"A\d+$");
foreach (var subCategory in configurations.Select(configuration => configuration.Replace(Build.InstallerConfiguration, "")))
if (string.IsNullOrEmpty(subCategory))
{
if (!string.IsNullOrEmpty(subConfigRegex.Match(directory).Value))
return project.GetExePath(Build.BuildConfiguration);
}
else
{
if (directory.EndsWith(subCategory))
return project.GetExePath($"{Build.BuildConfiguration}{subCategory}");
}
return null;
}
}