Fix quoting of arguments to handle things with spaces in them

This commit is contained in:
David Fowler 2015-10-22 03:32:32 -07:00
parent 893440aaef
commit f8837f7717
2 changed files with 5 additions and 6 deletions

View file

@ -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();

View file

@ -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;
}