提交 899fdc36 编写于 作者: M Manish Vasani 提交者: GitHub

Ensure that we normalize the CPSProject bin output path even when it … (#15019)

* Ensure that we normalize the CPSProject bin output path even when it is set via the property IWorkspaceProjectContext.BinOutputPath

* Fix unit test

* Make property internal for testing purposes

* Fix expected project file path in the test
上级 7fe93934
......@@ -87,6 +87,13 @@ public void ProjectOutputBinPathChange_CPS()
((IWorkspaceProjectContext)project).BinOutputPath = newBinPath;
Assert.Equal(newObjPath, project.ObjOutputPath);
Assert.Equal(newBinPath, project.BinOutputPath);
// Change bin output folder to non-normalized path - verify that binOutputPath changes to normalized path, but objOutputPath is the same.
newBinPath = @"test.dll";
var expectedNewBinPath = Path.Combine(Path.GetTempPath(), newBinPath);
((IWorkspaceProjectContext)project).BinOutputPath = newBinPath;
Assert.Equal(newObjPath, project.ObjOutputPath);
Assert.Equal(expectedNewBinPath, project.BinOutputPath);
}
}
......
......@@ -28,6 +28,15 @@ internal sealed partial class CPSProject : AbstractProject
ICommandLineParserService commandLineParserServiceOpt)
: base(projectTracker, reportExternalErrorCreatorOpt, projectDisplayName, projectFilePath,
hierarchy, language, projectGuid, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt, commandLineParserServiceOpt)
{
// We need to ensure that the bin output path for the project has been initialized before we hookup the project with the project tracker.
NormalizeAndSetBinOutputPathAndRelatedData(binOutputPath);
// Now hook up the project to the project tracker.
projectTracker.AddProject(this);
}
private void NormalizeAndSetBinOutputPathAndRelatedData(string binOutputPath)
{
if (binOutputPath != null)
{
......@@ -40,16 +49,13 @@ internal sealed partial class CPSProject : AbstractProject
else if (!PathUtilities.IsAbsolute(binOutputPath))
{
// Make it a rooted path.
var basePath = PathUtilities.IsAbsolute(projectFilePath) ? PathUtilities.GetDirectoryName(projectFilePath) : Path.GetTempPath();
var basePath = this.ContainingDirectoryPathOpt ?? Path.GetTempPath();
binOutputPath = PathUtilities.CombineAbsoluteAndRelativePaths(basePath, binOutputPath);
}
}
// We need to ensure that the bin output path for the project has been initialized before we hookup the project with the project tracker.
SetBinOutputPathAndRelatedData(binOutputPath);
// Now hook up the project to the project tracker.
projectTracker.AddProject(this);
}
// We might we invoked from a background thread, so schedule the disconnect on foreground task scheduler.
......
......@@ -69,7 +69,7 @@ string IWorkspaceProjectContext.BinOutputPath
}
set
{
SetBinOutputPathAndRelatedData(value);
NormalizeAndSetBinOutputPathAndRelatedData(value);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册