From f8837f7717758df04d3774e1a0454ac1f9d56aa2 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Thu, 22 Oct 2015 03:32:32 -0700 Subject: [PATCH] Fix quoting of arguments to handle things with spaces in them --- src/Microsoft.DotNet.Tools.Compiler/Program.cs | 8 ++++---- src/Microsoft.DotNet.Tools.Publish/Program.cs | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.DotNet.Tools.Compiler/Program.cs b/src/Microsoft.DotNet.Tools.Compiler/Program.cs index e495a8aca..9d17b3b3a 100644 --- a/src/Microsoft.DotNet.Tools.Compiler/Program.cs +++ b/src/Microsoft.DotNet.Tools.Compiler/Program.cs @@ -110,7 +110,7 @@ namespace Microsoft.DotNet.Tools.Compiler foreach (var projectDependency in Sort(projects)) { // Skip compiling project dependencies since we've already figured out the build order - var compileResult = Command.Create("dotnet-compile", $"--framework {projectDependency.Framework} --configuration {configuration} --no-project-dependencies {projectDependency.Project.ProjectDirectory}") + var compileResult = Command.Create("dotnet-compile", $"--framework {projectDependency.Framework} --configuration {configuration} --no-project-dependencies \"{projectDependency.Project.ProjectDirectory}\"") .ForwardStdOut() .ForwardStdErr() .Execute(); @@ -178,11 +178,11 @@ namespace Microsoft.DotNet.Tools.Compiler foreach (var dependency in dependencies) { compilerArgs.AddRange(dependency.CompilationAssemblies.Select(r => $"-r:\"{r}\"")); - compilerArgs.AddRange(dependency.SourceReferences); + compilerArgs.AddRange(dependency.SourceReferences.Select(s => $"\"{s}\"")); } // Add project source files - compilerArgs.AddRange(context.ProjectFile.Files.SourceFiles); + compilerArgs.AddRange(context.ProjectFile.Files.SourceFiles.Select(s => $"\"{s}\"")); if (!AddResources(context.ProjectFile, compilerArgs, intermediateOutputPath)) { @@ -294,7 +294,7 @@ namespace Microsoft.DotNet.Tools.Compiler // {file}.resx -> {file}.resources var resourcesFile = Path.Combine(intermediateOutputPath, name); - var result = Command.Create("resgen", $"{fileName} {resourcesFile}") + var result = Command.Create("resgen", $"\"{fileName}\" \"{resourcesFile}\"") .ForwardStdErr() .ForwardStdOut() .Execute(); diff --git a/src/Microsoft.DotNet.Tools.Publish/Program.cs b/src/Microsoft.DotNet.Tools.Publish/Program.cs index 847a83652..8c0d49986 100644 --- a/src/Microsoft.DotNet.Tools.Publish/Program.cs +++ b/src/Microsoft.DotNet.Tools.Publish/Program.cs @@ -98,14 +98,13 @@ namespace Microsoft.DotNet.Tools.Publish } // Compile the project (and transitively, all it's dependencies) - var result = Command.Create("dotnet-compile", $"--framework {context.TargetFramework.DotNetFrameworkName} {context.ProjectFile.ProjectDirectory}") + var result = Command.Create("dotnet-compile", $"--framework {context.TargetFramework.DotNetFrameworkName} \"{context.ProjectFile.ProjectDirectory}\"") .ForwardStdErr() .ForwardStdOut() .Execute(); if (result.ExitCode != 0) { - Reporter.Error.WriteLine("Compilation failed!".Red().Bold()); return result.ExitCode; }