forked from chuongmep/CadPythonShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuild.cs
More file actions
69 lines (60 loc) · 2.85 KB
/
Build.cs
File metadata and controls
69 lines (60 loc) · 2.85 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using Nuke.Common;
using Nuke.Common.Git;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tools.VSWhere;
using System.Text.RegularExpressions;
internal partial class Build : NukeBuild
{
private readonly AbsolutePath ArtifactsDirectory = RootDirectory / ArtifactsFolder;
private readonly AbsolutePath ChangeLogPath = RootDirectory / "CHANGELOG.md";
[GitRepository] private readonly GitRepository GitRepository;
[Solution] private readonly Solution Solution;
private static readonly Lazy<string> MsBuildPath = new(() =>
{
if (IsServerBuild) return null;
var (_, output) = VSWhereTasks.VSWhere(settings => settings
.EnableLatest()
.AddRequires("Microsoft.Component.MSBuild")
.SetProperty("installationPath")
);
if (output.Count > 0) return null;
if (!File.Exists(CustomMsBuildPath)) throw new Exception($"Missing file: {CustomMsBuildPath}. Change the path to the build platform or install Visual Studio.");
return CustomMsBuildPath;
});
public static int Main() => Execute<Build>(x => x.Cleaning);
private List<string> GetConfigurations(params string[] startPatterns)
{
var configurations = Solution.Configurations
.Select(pair => pair.Key)
.Where(s => startPatterns.Any(s.StartsWith))
.Select(s =>
{
var platformIndex = s.LastIndexOf('|');
return s.Remove(platformIndex);
})
.ToList();
if (configurations.Count == 0) throw new Exception($"Can't find configurations in the solution by patterns: {string.Join(" | ", startPatterns)}.");
configurations.ForEach(x => Console.WriteLine($"Fined Configuration Name: {x}"));
return configurations;
}
private IEnumerable<IGrouping<string, DirectoryInfo>> GetBuildDirectories()
{
var directories = new List<DirectoryInfo>();
foreach (var projectName in Projects)
{
Console.WriteLine($"Get Project Name: {projectName}");
var project = BuilderExtensions.GetProject(Solution, projectName);
Console.WriteLine($"Bin Directory: {project.GetBinDirectory()}");
var directoryInfo = new DirectoryInfo(project.GetBinDirectory()).GetDirectories();
directories.AddRange(directoryInfo);
}
if (directories.Count == 0) throw new Exception("There are no packaged assemblies in the project. Try to build the project again.");
var versionRegex = new Regex(@"^.*A\d+ ?");
var addInsDirectory = directories
//.Where(dir => dir.Name.StartsWith(AddInBinPrefix))
.Where(dir => dir.Name.Contains(BuildConfiguration))
.GroupBy(dir => versionRegex.Replace(dir.Name, string.Empty));
return addInsDirectory;
}
}