-
Notifications
You must be signed in to change notification settings - Fork 3
/
RunAndBuild.cs
63 lines (53 loc) · 2.45 KB
/
RunAndBuild.cs
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
using System;
using System.Diagnostics;
namespace cosmos {
public static class RunAndBuild {
public static void run() {
build();
if (RUN.current.runProfile == "QEMU") {
RUN.current.runCommand = RUN.current.runCommand.Replace("__ISO__", RUN.current.isoPath + RUN.current.csprojectPath.Replace(".csproj", ".iso"));
RunCommandWithBash(RUN.current.runCommand.Split(' ')[0], RUN.current.runCommand.TrimStart(RUN.current.runCommand.Split(' ')[0].ToCharArray()));
}
if (RUN.current.runProfile.ToLower() == "vmware") {
RunCommandWithBash("/usr/bin/cp", RUN.current.isoPath + "/" + RUN.current.isoName + ".iso" + " /etc/CosmosCLI/VMWARE/currentiso.iso");
RunCommandWithBash("/usr/bin/vmplayer", "/etc/CosmosCLI/VMWARE/Cosmos.vmx");
}
}
public static void build() {
RunCommandWithBash("dotnet", "build " + RUN.current.csprojectPath);
RunCommandWithBash("mkdir", "-p " + RUN.current.isoPath);
RunCommandWithBash("cp", "bin/cosmos/Debug/net6.0/" + RUN.current.csprojectPath.Replace(".csproj", ".iso") + " " + RUN.current.isoPath);
}
public static void RunCommandWithBash(string command, string args)
{
ProcessStartInfo psi = new()
{
FileName = "/usr/bin/bash",
Arguments = "-c \"" + command + " " + args + "\"",
UseShellExecute = false
};
using var p = Process.Start(psi);
p.WaitForExit();
}
public static void DirectRun(string command, string args)
{
ProcessStartInfo psi = new()
{
FileName = command,
Arguments = args,
UseShellExecute = false
};
using var p = Process.Start(psi);
p.WaitForExit();
}
}
public struct CosmosProjectConfig {
public string csprojectPath;
public bool versionMatches;
public string isoPath;
public string isoName;
public string runCommand;
public string runProfile;
public CosmosProjectConfig(string csProjectPath, bool versionMatching, string isoP, string isoname, string rCommand, string rProfile) { runCommand = rCommand; isoName = isoname; isoPath = isoP; csprojectPath = csProjectPath; versionMatches = versionMatching; runProfile = rProfile; }
}
}