diff --git a/src/Compilers/Core/MSBuildTask/ManagedCompiler.cs b/src/Compilers/Core/MSBuildTask/ManagedCompiler.cs index 41f2b3acce4b77ae8916c1b322a5461ffcbde9a6..0288de251868cc3dcb508941b38ca51e9517835f 100644 --- a/src/Compilers/Core/MSBuildTask/ManagedCompiler.cs +++ b/src/Compilers/Core/MSBuildTask/ManagedCompiler.cs @@ -72,6 +72,13 @@ public int CodePage get { return _store.GetOrDefault(nameof(CodePage), 0); } } + [Output] + public ITaskItem[] CommandLineArgs + { + set { _store[nameof(CommandLineArgs)] = value; } + get { return (ITaskItem[])_store[nameof(CommandLineArgs)]; } + } + public string DebugType { set { _store[nameof(DebugType)] = value; } @@ -187,6 +194,12 @@ public bool Prefer32Bit get { return _store.GetOrDefault(nameof(Prefer32Bit), false); } } + public bool ProvideCommandLineArgs + { + set { _store[nameof(ProvideCommandLineArgs)] = value; } + get { return _store.GetOrDefault(nameof(ProvideCommandLineArgs), false); } + } + public ITaskItem[] References { set { _store[nameof(References)] = value; } @@ -211,6 +224,12 @@ public ITaskItem[] ResponseFiles get { return (ITaskItem[])_store[nameof(ResponseFiles)]; } } + public bool SkipCompilerExecution + { + set { _store[nameof(SkipCompilerExecution)] = value; } + get { return _store.GetOrDefault(nameof(SkipCompilerExecution), false); } + } + public ITaskItem[] Sources { set @@ -312,6 +331,17 @@ protected override Encoding StandardOutputEncoding protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands) { + if (ProvideCommandLineArgs) + { + CommandLineArgs = GetArguments(commandLineCommands, responseFileCommands) + .Select(arg => new TaskItem(arg)).ToArray(); + } + + if (SkipCompilerExecution) + { + return 0; + } + if (!UseSharedCompilation || !String.IsNullOrEmpty(this.ToolPath)) { return base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands); @@ -321,6 +351,9 @@ protected override int ExecuteTool(string pathToTool, string responseFileCommand { try { + CompilerServerLogger.Log($"CommandLine = '{commandLineCommands}'"); + CompilerServerLogger.Log($"BuildResponseFile = '{responseFileCommands}'"); + var responseTask = BuildClient.TryRunServerCompilation( Language, TryGetClientDir() ?? Path.GetDirectoryName(pathToTool), @@ -496,9 +529,6 @@ public string GenerateResponseFileContents() /// private string[] GetArguments(string commandLineCommands, string responseFileCommands) { - CompilerServerLogger.Log($"CommandLine = '{commandLineCommands}'"); - CompilerServerLogger.Log($"BuildResponseFile = '{responseFileCommands}'"); - var commandLineArguments = CommandLineParser.SplitCommandLineIntoArguments(commandLineCommands, removeHashComments: true); var responseFileArguments = diff --git a/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets b/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets index 876789c758660618f261b87a16a43f3db239e91c..37270ab1ba15310bfef7209d108f11b915b1d3fa 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="" + Returns="@(CscCommandLineArgs)" DependsOnTargets="$(CoreCompileDependsOn)" >