From 74febf1533eb93bfa51d7ce1f5693e2c0846e099 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 17 Aug 2015 17:08:41 -0700 Subject: [PATCH] Produce argument array instead of large string --- .../Core/MSBuildTask/ManagedCompiler.cs | 28 +++++++++++-------- .../MSBuildTask/Microsoft.CSharp.Core.targets | 6 ++-- .../Microsoft.VisualBasic.Core.targets | 6 ++-- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/Compilers/Core/MSBuildTask/ManagedCompiler.cs b/src/Compilers/Core/MSBuildTask/ManagedCompiler.cs index f87082f01c6..b5325d8b174 100644 --- a/src/Compilers/Core/MSBuildTask/ManagedCompiler.cs +++ b/src/Compilers/Core/MSBuildTask/ManagedCompiler.cs @@ -73,10 +73,10 @@ public int CodePage } [Output] - public string CommandLineInvocation + public ITaskItem[] CommandLineArgs { - set { _store[nameof(CommandLineInvocation)] = value; } - get { return _store.GetOrDefault(nameof(CommandLineInvocation), string.Empty); } + set { _store[nameof(CommandLineArgs)] = value; } + get { return (ITaskItem[])_store[nameof(CommandLineArgs)]; } } public string DebugType @@ -194,10 +194,10 @@ public bool Prefer32Bit get { return _store.GetOrDefault(nameof(Prefer32Bit), false); } } - public bool ProvideCommandLineInvocation + public bool ProvideCommandLineArgs { - set { _store[nameof(ProvideCommandLineInvocation)] = value; } - get { return _store.GetOrDefault(nameof(ProvideCommandLineInvocation), false); } + set { _store[nameof(ProvideCommandLineArgs)] = value; } + get { return _store.GetOrDefault(nameof(ProvideCommandLineArgs), false); } } public ITaskItem[] References @@ -331,9 +331,10 @@ protected override Encoding StandardOutputEncoding protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands) { - if (ProvideCommandLineInvocation) + if (ProvideCommandLineArgs) { - CommandLineInvocation = GenerateResponseFileContents(); + CommandLineArgs = GetArguments(commandLineCommands, responseFileCommands, false) + .Select(arg => new TaskItem(arg)).ToArray(); } if (SkipCompilerExecution) @@ -354,7 +355,7 @@ protected override int ExecuteTool(string pathToTool, string responseFileCommand Language, TryGetClientDir() ?? Path.GetDirectoryName(pathToTool), CurrentDirectoryToUse(), - GetArguments(commandLineCommands, responseFileCommands), + GetArguments(commandLineCommands, responseFileCommands, true), _sharedCompileCts.Token, libEnvVariable: LibDirectoryToUse()); @@ -523,10 +524,13 @@ public string GenerateResponseFileContents() /// /// Get the command line arguments to pass to the compiler. /// - private string[] GetArguments(string commandLineCommands, string responseFileCommands) + private string[] GetArguments(string commandLineCommands, string responseFileCommands, bool emitServerLog) { - CompilerServerLogger.Log($"CommandLine = '{commandLineCommands}'"); - CompilerServerLogger.Log($"BuildResponseFile = '{responseFileCommands}'"); + if (emitServerLog) + { + CompilerServerLogger.Log($"CommandLine = '{commandLineCommands}'"); + CompilerServerLogger.Log($"BuildResponseFile = '{responseFileCommands}'"); + } var commandLineArguments = CommandLineParser.SplitCommandLineIntoArguments(commandLineCommands, removeHashComments: true); diff --git a/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets b/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets index b52435e394f..37270ab1ba1 100644 --- a/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets +++ b/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets @@ -19,7 +19,7 @@ @(_DebugSymbolsIntermediatePath); $(NonExistentFile); @(CustomAdditionalCompileOutputs)" - Returns="$(CscCommandLineInvocation)" + Returns="@(CscCommandLineArgs)" DependsOnTargets="$(CoreCompileDependsOn)" >