From dd103cf6a8a3aa71b523741a4b28189a47b67377 Mon Sep 17 00:00:00 2001 From: Bryan Date: Thu, 18 Feb 2016 10:26:00 -0800 Subject: [PATCH] fix dotnet-compile.deps.json space in the path issue. add test for space in the path with Preserve Compilation Context fix project.json update tests update test --- .../commands/dotnet-compile/ManagedCompiler.cs | 2 +- test/dotnet-compile.Tests/CompilerTests.cs | 18 ++++++++++++++++++ test/dotnet-compile.Tests/project.json | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/dotnet/commands/dotnet-compile/ManagedCompiler.cs b/src/dotnet/commands/dotnet-compile/ManagedCompiler.cs index 722f70382..960b2b97a 100644 --- a/src/dotnet/commands/dotnet-compile/ManagedCompiler.cs +++ b/src/dotnet/commands/dotnet-compile/ManagedCompiler.cs @@ -115,7 +115,7 @@ namespace Microsoft.DotNet.Tools.Compiler writer.Write(dependencyContext, fileStream); } - compilerArgs.Add($"--resource:{depsJsonFile},{context.ProjectFile.Name}.deps.json"); + compilerArgs.Add($"--resource:\"{depsJsonFile}\",{context.ProjectFile.Name}.deps.json"); } if (!AddNonCultureResources(context.ProjectFile, compilerArgs, intermediateOutputPath)) diff --git a/test/dotnet-compile.Tests/CompilerTests.cs b/test/dotnet-compile.Tests/CompilerTests.cs index d31e5ac80..c0ed48edb 100644 --- a/test/dotnet-compile.Tests/CompilerTests.cs +++ b/test/dotnet-compile.Tests/CompilerTests.cs @@ -88,6 +88,24 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests Assert.Contains("CA1018", result.StdErr); } + [Fact] + public void CompilingAppWithPreserveCompilationContextWithSpaceInThePathShouldSucceed() + { + var root = Temp.CreateDirectory(); + + var spaceBufferDirectory = root.CreateDirectory("space directory"); + var testAppDir = spaceBufferDirectory.CreateDirectory("TestAppCompilationContext"); + + CopyProjectToTempDir(Path.Combine(_testProjectsRoot, "TestAppCompilationContext"), testAppDir); + + var testProjectDir = Path.Combine(_testProjectsRoot, "TestAppCompilationContext", "TestApp"); + var testProject = Path.Combine(testProjectDir, "project.json"); + + var buildCommand = new BuildCommand(testProject); + + buildCommand.Execute().Should().Pass(); + } + private void CopyProjectToTempDir(string projectDir, TempDirectory tempDir) { // copy all the files to temp dir diff --git a/test/dotnet-compile.Tests/project.json b/test/dotnet-compile.Tests/project.json index dfad85839..6853f6a19 100644 --- a/test/dotnet-compile.Tests/project.json +++ b/test/dotnet-compile.Tests/project.json @@ -23,6 +23,7 @@ "../../TestAssets/TestProjects/TestLibraryWithAnalyzer/*", "../../TestAssets/TestProjects/TestAppWithLibrary/TestLibrary/*", "../../TestAssets/TestProjects/TestProjectWithCultureSpecificResource/*", + "../../TestAssets/TestProjects/TestAppCompilationContext/**/*", "../../TestAssets/TestProjects/global.json" ],