From f0195659d1ea0c2fd875593ab094911b4013fb86 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 24 Apr 2020 21:38:43 +0200 Subject: [PATCH] install beauty as a local tool instead of a global one --- GameBundle/.config/dotnet-tools.json | 12 ++++++++++++ GameBundle/GameBundle.csproj | 6 ++++++ GameBundle/Program.cs | 15 ++++++++------- Test/Bundle.bat | 2 +- 4 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 GameBundle/.config/dotnet-tools.json diff --git a/GameBundle/.config/dotnet-tools.json b/GameBundle/.config/dotnet-tools.json new file mode 100644 index 0000000..54c2e1d --- /dev/null +++ b/GameBundle/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "nulastudio.ncbeauty": { + "version": "1.2.8", + "commands": [ + "ncbeauty" + ] + } + } +} \ No newline at end of file diff --git a/GameBundle/GameBundle.csproj b/GameBundle/GameBundle.csproj index 5271f12..e709cf3 100644 --- a/GameBundle/GameBundle.csproj +++ b/GameBundle/GameBundle.csproj @@ -20,4 +20,10 @@ + + + PreserveNewest + + + diff --git a/GameBundle/Program.cs b/GameBundle/Program.cs index e3c3410..dba7fd1 100644 --- a/GameBundle/Program.cs +++ b/GameBundle/Program.cs @@ -14,7 +14,8 @@ namespace GameBundle { } private static int Run(Options options) { - if (RunProcess(options, "dotnet", "tool install nulastudio.ncbeauty -g") < 0) + // make sure all of the required tools are installed + if (RunProcess(options, "dotnet", "tool restore", AppDomain.CurrentDomain.BaseDirectory) != 0) return -1; var proj = GetProjectFile(options); @@ -30,15 +31,15 @@ namespace GameBundle { if (options.BuildWindows) { Console.WriteLine("Bundling for windows"); - Publish(options, proj, $"{bundleDir}/win", options.Publish32Bit ? "win-x86" : "win-x64"); + Publish(options, proj, $"{bundleDir.FullName}/win", options.Publish32Bit ? "win-x86" : "win-x64"); } if (options.BuildLinux) { Console.WriteLine("Bundling for linux"); - Publish(options, proj, $"{bundleDir}/linux", "linux-x64"); + Publish(options, proj, $"{bundleDir.FullName}/linux", "linux-x64"); } if (options.BuildMac) { Console.WriteLine("Bundling for mac"); - var dir = $"{bundleDir}/mac"; + var dir = $"{bundleDir.FullName}/mac"; Publish(options, proj, dir, "osx-x64"); if (options.MacBundle) CreateMacBundle(options, new DirectoryInfo(dir), proj.FullName); @@ -54,7 +55,7 @@ namespace GameBundle { // Run beauty var excludes = '"' + string.Join(";", options.ExcludedFiles) + '"'; var log = options.Verbose ? "Detail" : "Error"; - RunProcess(options, "ncbeauty", $"--loglevel={log} --force=True {path} {options.LibFolder} --excludes={excludes}"); + RunProcess(options, "dotnet", $"ncbeauty --loglevel={log} --force=True {path} {options.LibFolder} {excludes}", AppDomain.CurrentDomain.BaseDirectory); // Remove the beauty file since it's just a marker var beautyFile = new FileInfo(Path.Combine(path, "NetCoreBeauty")); @@ -62,10 +63,10 @@ namespace GameBundle { beautyFile.Delete(); } - private static int RunProcess(Options options, string program, string args) { + private static int RunProcess(Options options, string program, string args, string workingDir = "") { if (options.Verbose) Console.WriteLine($"> {program} {args}"); - var info = new ProcessStartInfo(program, args); + var info = new ProcessStartInfo(program, args) {WorkingDirectory = workingDir}; if (!options.Verbose) info.CreateNoWindow = true; var process = Process.Start(info); diff --git a/Test/Bundle.bat b/Test/Bundle.bat index 9f7072c..1a99423 100644 --- a/Test/Bundle.bat +++ b/Test/Bundle.bat @@ -1 +1 @@ -"../GameBundle/bin/Debug/netcoreapp3.1/GameBundle.exe" -wlm -s Test.csproj -o bin/Bundled -v -b \ No newline at end of file +"../GameBundle/bin/Debug/netcoreapp3.1/GameBundle.exe" -w -s Test.csproj -o bin/Bundled -v -b \ No newline at end of file