cleaned up the build script and added a clean task

This commit is contained in:
Ell 2022-11-22 19:17:33 +01:00
parent 260d3437ab
commit 438d203bc9

View file

@ -7,25 +7,28 @@ var config = Argument("configuration", "Release");
var tinyLifeDir = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/Tiny Life"; var tinyLifeDir = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/Tiny Life";
Task("Clean").Does(() => {
EnsureDirectoryDoesNotExist($"bin/{config}");
EnsureDirectoryDoesNotExist($"{tinyLifeDir}/Mods/_Dev");
});
Task("Build").DoesForEach(GetFiles("**/*.csproj"), p => { Task("Build").DoesForEach(GetFiles("**/*.csproj"), p => {
DeleteFiles($"bin/{config}/**/*"); DotNetBuild(p.FullPath, new DotNetBuildSettings {
DotNetBuild(p.FullPath, new DotNetBuildSettings { Configuration = config }); Configuration = config
});
}); });
Task("CopyToMods").IsDependentOn("Build").Does(() => { Task("CopyToMods").IsDependentOn("Build").Does(() => {
var dir = $"{tinyLifeDir}/Mods"; var dir = $"{tinyLifeDir}/Mods/_Dev";
CreateDirectory(dir); EnsureDirectoryExists(dir);
var files = GetFiles($"bin/{config}/net*/**/*"); var files = GetFiles($"bin/{config}/net*/**/*");
CopyFiles(files, dir, true); CopyFiles(files, dir, true);
}); });
Task("Run").IsDependentOn("CopyToMods").Does(() => { Task("Run").IsDependentOn("CopyToMods").Does(() => {
// start the tiny life process // start the tiny life process
var exeDir = $"{tinyLifeDir}/GameDir"; var exeDir = System.IO.File.ReadAllText($"{tinyLifeDir}/GameDir");
if (!FileExists(exeDir)) var process = Process.Start(new ProcessStartInfo($"{exeDir}/Tiny Life") {
throw new Exception("Didn't find game directory information. Run the game manually at least once to allow the Run task to be executed.");
var exe = $"{System.IO.File.ReadAllText(exeDir)}/Tiny Life";
var process = Process.Start(new ProcessStartInfo(exe) {
Arguments = "-v --skip-splash --skip-preloads", Arguments = "-v --skip-splash --skip-preloads",
CreateNoWindow = true CreateNoWindow = true
}); });