diff --git a/src/Tools/CommandLine/CompilerCommands.cs b/src/Tools/CommandLine/CompilerCommands.cs index 6b52d76ce0..3bdb2eff96 100644 --- a/src/Tools/CommandLine/CompilerCommands.cs +++ b/src/Tools/CommandLine/CompilerCommands.cs @@ -89,9 +89,12 @@ public static int HandleLint( var pinfo = new ProcessStartInfo { FileName = executable, - UseShellExecute = false, - Arguments = string.Join(' ', compilerArgs) + UseShellExecute = false }; + foreach (var a in compilerArgs) + { + pinfo.ArgumentList.Add(a); + } var process = System.Diagnostics.Process.Start(pinfo); process.WaitForExit(); diff --git a/src/Tools/CommandLine/MSBuild.cs b/src/Tools/CommandLine/MSBuild.cs index d62491c914..3cac476d52 100644 --- a/src/Tools/CommandLine/MSBuild.cs +++ b/src/Tools/CommandLine/MSBuild.cs @@ -8,6 +8,7 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using NuGet.Frameworks; +using DotVVM.Framework.Utils; namespace DotVVM.CommandLine { @@ -42,7 +43,7 @@ public static MSBuild CreateFromSdk() var startInfo = new ProcessStartInfo { - Arguments = "-property installationPath", + ArgumentList = { "-property", "installationPath" }, RedirectStandardOutput = true, FileName = vswhere.FullName, UseShellExecute = false, @@ -116,7 +117,7 @@ public bool TryInvoke( startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardError = true; } - logger.LogDebug($"Invoking MSBuild with args: '{startInfo.Arguments}'."); + logger.LogDebug($"Invoking MSBuild with args: '{startInfo.ArgumentList.StringJoin(" ")}'."); var process = Process.Start(startInfo); if (!showOutput) { @@ -140,7 +141,7 @@ public bool TryInvoke( var startInfo = GetProcessStartInfo(project, properties, targets, restore, verbosity); startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardError = true; - logger.LogDebug($"Invoking MSBuild with args: '{startInfo.Arguments}'."); + logger.LogDebug($"Invoking MSBuild with args: '{startInfo.ArgumentList.StringJoin(" ")}'."); var process = Process.Start(startInfo); var stderrTask = Task.Run(() => process.StandardError.ReadToEnd()); @@ -171,31 +172,34 @@ private ProcessStartInfo GetProcessStartInfo( bool restore = false, string verbosity = "minimal") { - var sb = new StringBuilder(); - sb.Append(string.Join(" ", PrefixedArgs)); + var p = new ProcessStartInfo + { + FileName = ExecutablePath + }; + foreach (var a in PrefixedArgs) + { + p.ArgumentList.Add(a); + } if (restore) { - sb.Append(" -restore"); + p.ArgumentList.Add("-restore"); } - sb.Append($" -verbosity:{verbosity}"); + p.ArgumentList.Add($"-verbosity:{verbosity}"); if (properties is object) { foreach(var property in properties) { - sb.Append($" -property:{property.Key}={property.Value}"); + p.ArgumentList.Add($"-property:{property.Key}={property.Value}"); } } if (targets is object) { - sb.Append($" -target:{string.Join(";", targets)}"); + p.ArgumentList.Add($"-target:{string.Join(";", targets)}"); } - sb.Append($" {project.FullName}"); - return new ProcessStartInfo - { - FileName = ExecutablePath, - Arguments = sb.ToString() - }; + p.ArgumentList.Add($"{project.FullName}"); + + return p; } } }