diff --git a/ref/Microsoft.Build.Tasks.Core/net/Microsoft.Build.Tasks.Core.cs b/ref/Microsoft.Build.Tasks.Core/net/Microsoft.Build.Tasks.Core.cs index ad59f4d890f..c94de3e3688 100644 --- a/ref/Microsoft.Build.Tasks.Core/net/Microsoft.Build.Tasks.Core.cs +++ b/ref/Microsoft.Build.Tasks.Core/net/Microsoft.Build.Tasks.Core.cs @@ -333,7 +333,6 @@ public Exec() { } [Microsoft.Build.Framework.OutputAttribute] public string StdOutEncoding { get { throw null; } set { } } protected override string ToolName { get { throw null; } } - public string UseUtf8Encoding { get { throw null; } set { } } public string WorkingDirectory { get { throw null; } set { } } protected internal override void AddCommandLineCommands(Microsoft.Build.Tasks.CommandLineBuilderExtension commandLine) { } protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands) { throw null; } diff --git a/ref/Microsoft.Build.Tasks.Core/netstandard/Microsoft.Build.Tasks.Core.cs b/ref/Microsoft.Build.Tasks.Core/netstandard/Microsoft.Build.Tasks.Core.cs index 14e40af12dd..1cefcd56250 100644 --- a/ref/Microsoft.Build.Tasks.Core/netstandard/Microsoft.Build.Tasks.Core.cs +++ b/ref/Microsoft.Build.Tasks.Core/netstandard/Microsoft.Build.Tasks.Core.cs @@ -263,7 +263,6 @@ public Exec() { } [Microsoft.Build.Framework.OutputAttribute] public string StdOutEncoding { get { throw null; } set { } } protected override string ToolName { get { throw null; } } - public string UseUtf8Encoding { get { throw null; } set { } } public string WorkingDirectory { get { throw null; } set { } } protected internal override void AddCommandLineCommands(Microsoft.Build.Tasks.CommandLineBuilderExtension commandLine) { } protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands) { throw null; } diff --git a/ref/Microsoft.Build.Utilities.Core/net/Microsoft.Build.Utilities.Core.cs b/ref/Microsoft.Build.Utilities.Core/net/Microsoft.Build.Utilities.Core.cs index 604210eaa06..4a6e7852359 100644 --- a/ref/Microsoft.Build.Utilities.Core/net/Microsoft.Build.Utilities.Core.cs +++ b/ref/Microsoft.Build.Utilities.Core/net/Microsoft.Build.Utilities.Core.cs @@ -555,6 +555,7 @@ protected ToolTask(System.Resources.ResourceManager taskResources, string helpKe protected abstract string ToolName { get; } public string ToolPath { get { throw null; } set { } } public bool UseCommandProcessor { get { throw null; } set { } } + public string UseUtf8Encoding { get { throw null; } set { } } public bool YieldDuringToolExecution { get { throw null; } set { } } protected virtual string AdjustCommandsForOperatingSystem(string input) { throw null; } protected virtual bool CallHostObjectToExecute() { throw null; } diff --git a/ref/Microsoft.Build.Utilities.Core/netstandard/Microsoft.Build.Utilities.Core.cs b/ref/Microsoft.Build.Utilities.Core/netstandard/Microsoft.Build.Utilities.Core.cs index dc633b0e922..52dda23db52 100644 --- a/ref/Microsoft.Build.Utilities.Core/netstandard/Microsoft.Build.Utilities.Core.cs +++ b/ref/Microsoft.Build.Utilities.Core/netstandard/Microsoft.Build.Utilities.Core.cs @@ -395,6 +395,7 @@ protected ToolTask(System.Resources.ResourceManager taskResources, string helpKe protected abstract string ToolName { get; } public string ToolPath { get { throw null; } set { } } public bool UseCommandProcessor { get { throw null; } set { } } + public string UseUtf8Encoding { get { throw null; } set { } } public bool YieldDuringToolExecution { get { throw null; } set { } } protected virtual string AdjustCommandsForOperatingSystem(string input) { throw null; } protected virtual bool CallHostObjectToExecute() { throw null; } diff --git a/src/Tasks/Exec.cs b/src/Tasks/Exec.cs index 0cf22b566c5..2132b8266db 100644 --- a/src/Tasks/Exec.cs +++ b/src/Tasks/Exec.cs @@ -123,14 +123,6 @@ public string CustomWarningRegularExpression /// protected override Encoding StandardErrorEncoding => _standardErrorEncoding; - /// - /// Whether or not to use UTF8 encoding for the cmd file and console window. - /// Values: Always, Never, Detect - /// If set to Detect, the current code page will be used unless it cannot represent - /// the Command string. In that case, UTF-8 is used. - /// - public string UseUtf8Encoding { get; set; } - /// /// Project visible property specifying the encoding of the captured task standard output stream /// diff --git a/src/Utilities/ToolTask.cs b/src/Utilities/ToolTask.cs index 5ccd30763e2..e7766038d11 100644 --- a/src/Utilities/ToolTask.cs +++ b/src/Utilities/ToolTask.cs @@ -182,6 +182,14 @@ public virtual string ToolExe /// Path to tool. public string ToolPath { set; get; } + /// + /// Whether or not to use UTF8 encoding for the cmd file and console window. + /// Values: Always, Never, Detect + /// If set to Detect, the current code page will be used unless it cannot represent + /// the Command string. In that case, UTF-8 is used. + /// + public string UseUtf8Encoding { get; set; } = EncodingUtilities.UseUtf8Detect; + /// /// Array of equals-separated pairs of environment /// variables that should be passed to the spawned executable, @@ -1372,7 +1380,7 @@ public override bool Execute() } else { - encoding = EncodingUtilities.BatchFileEncoding(commandLineCommands + _temporaryBatchFile, EncodingUtilities.UseUtf8Detect); + encoding = EncodingUtilities.BatchFileEncoding(commandLineCommands + _temporaryBatchFile, UseUtf8Encoding); if (encoding.CodePage != EncodingUtilities.CurrentSystemOemEncoding.CodePage) {