diff --git a/src/Build.UnitTests/Construction/SolutionFile_Tests.cs b/src/Build.UnitTests/Construction/SolutionFile_Tests.cs
index fbccc9a28bb..58a0d5dcf37 100644
--- a/src/Build.UnitTests/Construction/SolutionFile_Tests.cs
+++ b/src/Build.UnitTests/Construction/SolutionFile_Tests.cs
@@ -698,6 +698,35 @@ public void ParseFirstProjectLineWhereProjectNameHasSpecialCharacters()
Assert.Equal("Unique name-GUID", proj.ProjectGuid);
}
+ ///
+ /// Test some characters that are valid in a file name but that also could be
+ /// considered a delimiter by a parser. Does quoting work for special characters?
+ ///
+ [Fact]
+ public void ParseFirstProjectLineWhereProjectPathHasBackslash()
+ {
+ using (var env = TestEnvironment.Create())
+ {
+ var solutionFolder = env.CreateFolder(Path.Combine(FileUtilities.GetTemporaryDirectory(), "sln"));
+ var projectFolder = env.CreateFolder(Path.Combine(solutionFolder.FolderPath, "RelativePath"));
+
+ SolutionFile p = new SolutionFile();
+ p.FullPath = Path.Combine(solutionFolder.FolderPath, "RelativePath", "project file");
+ p.SolutionFileDirectory = Path.GetFullPath(solutionFolder.FolderPath);
+ ProjectInSolution proj = new ProjectInSolution(p);
+
+ p.ParseFirstProjectLine
+ (
+ "Project(\"{Project GUID}\") = \"ProjectInSubdirectory\", \"RelativePath\\project file\" , \"Unique name-GUID\"",
+ proj
+ );
+ Assert.Equal(SolutionProjectType.Unknown, proj.ProjectType);
+ Assert.Equal("ProjectInSubdirectory", proj.ProjectName);
+ Assert.Equal(Path.Combine("RelativePath", "project file"), proj.RelativePath);
+ Assert.Equal("Unique name-GUID", proj.ProjectGuid);
+ }
+ }
+
///
/// Helper method to create a SolutionFile object, and call it to parse the SLN file
/// represented by the string contents passed in.
diff --git a/src/Build/Construction/Solution/ProjectInSolution.cs b/src/Build/Construction/Solution/ProjectInSolution.cs
index 453879eb1b9..ffe522502b8 100644
--- a/src/Build/Construction/Solution/ProjectInSolution.cs
+++ b/src/Build/Construction/Solution/ProjectInSolution.cs
@@ -8,6 +8,7 @@
using System.Security;
using System.Text;
using System.Xml;
+using Microsoft.Build.Shared;
using XMakeAttributes = Microsoft.Build.Shared.XMakeAttributes;
using ProjectFileErrorUtilities = Microsoft.Build.Shared.ProjectFileErrorUtilities;
@@ -155,7 +156,11 @@ public string ProjectName
public string RelativePath
{
get { return _relativePath; }
- internal set { _relativePath = value; }
+ internal set
+ {
+ _relativePath = FileUtilities.MaybeAdjustFilePath(value,
+ baseDirectory:this.ParentSolution.SolutionFileDirectory ?? String.Empty);
+ }
}
///