-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram_BuildMods.cs
More file actions
48 lines (40 loc) · 1.68 KB
/
Program_BuildMods.cs
File metadata and controls
48 lines (40 loc) · 1.68 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
using System.IO.Compression;
namespace SC_NewUniversalUpload
{
internal partial class Program
{
/// <summary>
/// Builds all edited mods via MSBuild.
/// </summary>
/// <param name="updatedFiles"></param>
public void BuildMods(HashSet<string> updatedFiles)
{
Console.WriteLine("Changed files:\n- " + string.Join("\n- ", updatedFiles));
int updatedModsCt = 0;
foreach (var modPath in LocateAllMods(Arguments["--repo"]))
{
// If any files in the mod were updated, build it.
var wasThisModUpdated =
updatedFiles.Any(editedFile => Path.Join(Arguments["--repo"], editedFile).Contains(modPath));
if (!wasThisModUpdated)
continue;
BuildMod(modPath);
updatedModsCt++;
}
Console.WriteLine($"Built {updatedModsCt} mods.");
}
private void BuildMod(string modPath)
{
Console.WriteLine($"Starting build for {modPath}...");
// Pull generic SLN files
ZipFile.ExtractToDirectory(Path.Join(Arguments["--repo"], "VisualStudioSLNs.zip"), modPath, true);
RunCmd(Config.MsBuildPath, $"\"{Path.Join(modPath, "Generic.sln")}\" -restore -noWarn:NU1903,CS0649 -verbosity:m", out var stdout); // TODO -verbosity:m
if (stdout.Contains("error"))
{
Console.Error.WriteLine($"Failed to build \"{modPath}\"!");
Console.Error.WriteLine("| " + stdout.ReplaceLineEndings("\n| "));
Environment.ExitCode = 1;
}
}
}
}