From 34d1f859a75291722e724892997787c5c82257ab Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 29 Mar 2023 16:08:19 +0100 Subject: [PATCH] [ci skip] ci(upm): output package.json instead of print to stdout --- X10D.UpmPackageGenerator/Program.cs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/X10D.UpmPackageGenerator/Program.cs b/X10D.UpmPackageGenerator/Program.cs index b57e095..5fd345d 100644 --- a/X10D.UpmPackageGenerator/Program.cs +++ b/X10D.UpmPackageGenerator/Program.cs @@ -7,17 +7,19 @@ if (args.Length == 0 || string.IsNullOrWhiteSpace(args[0])) { version = Environment.GetEnvironmentVariable("GITHUB_SHA") ?? "0.0.0"; } - -string path = args[0]; -var assembly = Assembly.LoadFrom(path); -var attribute = assembly.GetCustomAttribute(); -if (attribute is null || string.IsNullOrWhiteSpace(attribute.InformationalVersion)) -{ - version = Environment.GetEnvironmentVariable("GITHUB_SHA") ?? "0.0.0"; -} else { - version = attribute.InformationalVersion; + string path = args[0]; + var assembly = Assembly.LoadFrom(path); + var attribute = assembly.GetCustomAttribute(); + if (attribute is null || string.IsNullOrWhiteSpace(attribute.InformationalVersion)) + { + version = Environment.GetEnvironmentVariable("GITHUB_SHA") ?? "0.0.0"; + } + else + { + version = attribute.InformationalVersion; + } } var package = new @@ -33,4 +35,5 @@ var package = new licensesUrl = "https://github.com/oliverbooth/X10D/blob/main/LICENSE.md" }; -Console.WriteLine(JsonSerializer.Serialize(package, new JsonSerializerOptions {WriteIndented = true})); +using FileStream outputStream = File.Create("package.json"); +JsonSerializer.Serialize(outputStream, package, new JsonSerializerOptions {WriteIndented = true});