diff --git a/.github/actions/setup-msvc-env/action.yml b/.github/actions/setup-msvc-env/action.yml index 051f189b46..41705c24e8 100644 --- a/.github/actions/setup-msvc-env/action.yml +++ b/.github/actions/setup-msvc-env/action.yml @@ -122,6 +122,7 @@ runs: using System; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Text; internal static class Program @@ -144,7 +145,7 @@ internal static class Program { if (!string.Equals(arg, "/arm64hazardfree", StringComparison.OrdinalIgnoreCase)) { - filteredArgs.Add(QuoteArgument(arg)); + filteredArgs.Add(QuoteArgument(FilterResponseFile(arg))); } } startInfo.Arguments = string.Join(" ", filteredArgs); @@ -160,6 +161,25 @@ internal static class Program return process.ExitCode; } + private static string FilterResponseFile(string argument) + { + if (argument.Length < 2 || argument[0] != '@') + { + return argument; + } + + var responsePath = argument.Substring(1); + if (!File.Exists(responsePath)) + { + return argument; + } + + var filteredResponsePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".rsp"); + var responseContents = File.ReadAllText(responsePath).Replace("/arm64hazardfree", string.Empty); + File.WriteAllText(filteredResponsePath, responseContents); + return "@" + filteredResponsePath; + } + private static string QuoteArgument(string argument) { if (argument.Length == 0)