## Summary Replaces the basic `publish.cmd`/`publish.sh` scripts with an interactive **BuildTool** — a C# console app using [Spectre.Console](https://spectreconsole.net/) that guides users through publishing, prerequisite checking, and cross-compilation. ### Why The community found the existing publish scripts unhelpful for newcomers. They worked but didn't walk users through the process, didn't check prerequisites, and provided no feedback when things went wrong. ### What's New **Interactive BuildTool** (`Projects/BuildTool/`) - NativeAOT-compiled C# console app with true-color ASCII logo and ModernUO brand gold/silver palette - Guided publish wizard with step-by-step back navigation (Ctrl+C or menu "Back" to go to previous step) - Prerequisite checking: .NET SDK version, VC++ Redistributable (Windows), native libraries (Linux/macOS) - .NET SDK auto-install offer via Microsoft's official install scripts - Platform detection: Windows 10 vs 11 (build number), macOS codenames, Linux distro + kernel version - Cross-compilation support: skips native library checks, shows target prerequisites after build - Non-interactive mode for CI: `--config Release --skip-prereqs` - Backward-compatible positional args: `publish.cmd release win x64` still works **Shell Wrappers** (`publish.cmd`, `publish.ps1`, `publish.sh`) - Try native BuildTool binary first (downloaded from GitHub Releases) - Fall back to `dotnet run --project Projects/BuildTool` if unavailable - SDK bootstrapping: offer to install .NET if not found **CI/CD Updates** - Build/test workflows target `Projects/Application/Application.csproj` instead of the solution (excludes BuildTool and test projects from publish) - New `build-tool-release.yml` workflow builds NativeAOT binaries for win-x64, win-arm64, osx-arm64, linux-x64, linux-arm64 - Minimum SDK bumped to 10.0.201 (required for Serialization Generator 2.14.3 / Roslyn 5.3.0) **Other Changes** - Solution converted from `.sln` to `.slnx` - Updated README with interactive mode instructions and deployment guidance ## Screenshots <img width="320" height="378" alt="image" src="https://github.com/user-attachments/assets/83c057c5-3992-4dbd-99fa-0e3c24ef6428" /> <img width="749" height="554" alt="image" src="https://github.com/user-attachments/assets/e4ee4d6f-71d4-47f9-86b6-8fd1ca3c3e7a" />
126 lines
4.1 KiB
C#
126 lines
4.1 KiB
C#
using Spectre.Console;
|
|
|
|
namespace BuildTool.Publishing;
|
|
|
|
public static class SchemaMigrator
|
|
{
|
|
public static int Run(bool interactive)
|
|
{
|
|
if (interactive)
|
|
{
|
|
return RunInteractive();
|
|
}
|
|
|
|
return RunNonInteractive();
|
|
}
|
|
|
|
private static int RunInteractive()
|
|
{
|
|
var panel = new Panel("[bold]Running schema migration[/]")
|
|
.Border(BoxBorder.Rounded)
|
|
.BorderColor(Branding.Gold)
|
|
.Padding(1, 0);
|
|
AnsiConsole.Write(panel);
|
|
AnsiConsole.WriteLine();
|
|
|
|
// Tool restore
|
|
{
|
|
var exitCode = 0;
|
|
string errorOutput = "";
|
|
|
|
AnsiConsole.Status()
|
|
.Spinner(Spinner.Known.Dots)
|
|
.SpinnerStyle(Branding.GoldStyle)
|
|
.Start("[grey](1/2)[/] Restoring tools...", _ =>
|
|
{
|
|
var result = ProcessRunner.RunCaptured("dotnet", "tool restore");
|
|
exitCode = result.ExitCode;
|
|
errorOutput = result.StandardError;
|
|
});
|
|
|
|
if (exitCode == 0)
|
|
{
|
|
AnsiConsole.MarkupLine(" [green]:check_mark:[/] [grey](1/2)[/] Tools restored");
|
|
}
|
|
else
|
|
{
|
|
AnsiConsole.MarkupLine(" [red]:cross_mark:[/] [grey](1/2)[/] Tool restore [red](failed)[/]");
|
|
if (!string.IsNullOrWhiteSpace(errorOutput))
|
|
{
|
|
AnsiConsole.Write(new Panel(Markup.Escape(errorOutput.Trim()))
|
|
.Header("[red]Error[/]")
|
|
.Border(BoxBorder.Rounded)
|
|
.BorderColor(Color.Red));
|
|
}
|
|
|
|
return exitCode;
|
|
}
|
|
}
|
|
|
|
// Schema generation
|
|
{
|
|
var exitCode = 0;
|
|
string errorOutput = "";
|
|
|
|
AnsiConsole.Status()
|
|
.Spinner(Spinner.Known.Dots)
|
|
.SpinnerStyle(Branding.GoldStyle)
|
|
.Start("[grey](2/2)[/] Generating serialization schema...", _ =>
|
|
{
|
|
var result = ProcessRunner.RunCaptured(
|
|
"dotnet",
|
|
"tool run ModernUOSchemaGenerator -- ModernUO.slnx"
|
|
);
|
|
exitCode = result.ExitCode;
|
|
errorOutput = result.StandardError;
|
|
});
|
|
|
|
if (exitCode == 0)
|
|
{
|
|
AnsiConsole.MarkupLine(" [green]:check_mark:[/] [grey](2/2)[/] Schema generated");
|
|
}
|
|
else
|
|
{
|
|
AnsiConsole.MarkupLine(" [red]:cross_mark:[/] [grey](2/2)[/] Schema generation [red](failed)[/]");
|
|
if (!string.IsNullOrWhiteSpace(errorOutput))
|
|
{
|
|
AnsiConsole.Write(new Panel(Markup.Escape(errorOutput.Trim()))
|
|
.Header("[red]Error[/]")
|
|
.Border(BoxBorder.Rounded)
|
|
.BorderColor(Color.Red));
|
|
}
|
|
|
|
return exitCode;
|
|
}
|
|
}
|
|
|
|
AnsiConsole.WriteLine();
|
|
AnsiConsole.Write(new Panel("[green bold]:check_mark_button: Schema migration complete.[/]")
|
|
.Border(BoxBorder.Rounded)
|
|
.BorderColor(Color.Green)
|
|
.Padding(1, 0));
|
|
AnsiConsole.WriteLine();
|
|
return 0;
|
|
}
|
|
|
|
private static int RunNonInteractive()
|
|
{
|
|
Console.WriteLine("dotnet tool restore");
|
|
var exitCode = ProcessRunner.RunPassthrough("dotnet", "tool restore");
|
|
if (exitCode != 0)
|
|
{
|
|
Console.Error.WriteLine($"Error: tool restore failed with exit code {exitCode}");
|
|
return exitCode;
|
|
}
|
|
|
|
Console.WriteLine("Generating serialization migration schema...");
|
|
exitCode = ProcessRunner.RunPassthrough("dotnet", "tool run ModernUOSchemaGenerator -- ModernUO.slnx");
|
|
if (exitCode != 0)
|
|
{
|
|
Console.Error.WriteLine($"Error: schema generation failed with exit code {exitCode}");
|
|
return exitCode;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|