From 381ffec9283caca75d302b03bd948ac5511ee4e1 Mon Sep 17 00:00:00 2001 From: Antoine Aubry Date: Thu, 8 Apr 2021 16:58:08 +0100 Subject: [PATCH] Fix repository name detection on AppVeyor --- tools/build/BuildDefinition.cs | 9 +++++++-- tools/build/Program.cs | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/build/BuildDefinition.cs b/tools/build/BuildDefinition.cs index a80848188..cd10de4fd 100644 --- a/tools/build/BuildDefinition.cs +++ b/tools/build/BuildDefinition.cs @@ -439,8 +439,13 @@ public static void Document(Options options) "); } - private static string GitHubRepository => Environment.GetEnvironmentVariable("GITHUB_REPOSITORY") ?? "aaubry/YamlDotNet.Sandbox"; - + private static string GitHubRepository => + Program.Host switch + { + Host.Appveyor => Environment.GetEnvironmentVariable("APPVEYOR_REPO_NAME"), + _ => Environment.GetEnvironmentVariable("GITHUB_REPOSITORY") + } + ?? "aaubry/YamlDotNet.Sandbox"; private static readonly Lazy GitHubClient = new Lazy(() => { diff --git a/tools/build/Program.cs b/tools/build/Program.cs index 962667d7e..e29c7e3e5 100644 --- a/tools/build/Program.cs +++ b/tools/build/Program.cs @@ -22,7 +22,7 @@ class Program public static bool NoPrerelease { get; private set; } public static string? ForcedVersion { get; private set; } private static bool verbose; - private static Host host; + public static Host Host { get; private set; } private static readonly Dictionary state = new Dictionary(); private static T GetState() where T : notnull @@ -136,7 +136,7 @@ static int Main(string[] args) var (options, targets) = Options.Parse(filteredArguments); verbose = options.Verbose; - host = options.Host.DetectIfUnknown().Item1; + Host = options.Host.DetectIfUnknown().Item1; var operatingSystem = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) @@ -234,7 +234,7 @@ public static void WriteWarning(string text) public static void WriteImportant(string text) { - switch (host) + switch (Host) { case Host.GitHubActions: Console.WriteLine($"Writing a warning");