Ensure tool package store root is a full path.

This commit fixes the tool package store such that it stores a full path
instead of, potentially, a relative path.

This prevents a relative path from inadvertently being passed to NuGet
during the restore and causing it to restore relative to the temp project
directory.

Fixes #8829.
This commit is contained in:
Peter Huene 2018-03-16 19:47:34 -07:00
parent cee0a3baa7
commit 4f8ac7dce5
No known key found for this signature in database
GPG key ID: E1D265D820213D6A
4 changed files with 9 additions and 5 deletions

View file

@ -14,7 +14,7 @@ namespace Microsoft.DotNet.ToolPackage
public ToolPackageStore(DirectoryPath root)
{
Root = root;
Root = new DirectoryPath(Path.GetFullPath(root.Value));
}
public DirectoryPath Root { get; private set; }

View file

@ -685,7 +685,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests
FilePath? tempProject = null,
DirectoryPath? offlineFeed = null)
{
var root = new DirectoryPath(Path.Combine(Path.GetFullPath(TempRoot.Root), Path.GetRandomFileName()));
var root = new DirectoryPath(Path.Combine(TempRoot.Root, Path.GetRandomFileName()));
var reporter = new BufferedReporter();
IFileSystem fileSystem;
@ -714,6 +714,8 @@ namespace Microsoft.DotNet.ToolPackage.Tests
offlineFeed: offlineFeed ?? new DirectoryPath("does not exist"));
}
store.Root.Value.Should().Be(Path.GetFullPath(root.Value));
return (store, installer, reporter, fileSystem);
}

View file

@ -22,7 +22,7 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks
IFileSystem fileSystem,
Action uninstallCallback = null)
{
Root = root;
Root = new DirectoryPath(Path.GetFullPath(root.Value));
_fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
_uninstallCallback = uninstallCallback;
}

View file

@ -73,7 +73,8 @@ namespace Microsoft.DotNet.Tests.Commands
PackageId,
PackageVersion));
var packageDirectory = new DirectoryPath(ToolsDirectory).WithSubDirectories(PackageId, PackageVersion);
var packageDirectory = new DirectoryPath(Path.GetFullPath(ToolsDirectory))
.WithSubDirectories(PackageId, PackageVersion);
var shimPath = Path.Combine(
ShimsDirectory,
ProjectRestorerMock.FakeCommandName +
@ -114,7 +115,8 @@ namespace Microsoft.DotNet.Tests.Commands
PackageId,
PackageVersion));
var packageDirectory = new DirectoryPath(ToolsDirectory).WithSubDirectories(PackageId, PackageVersion);
var packageDirectory = new DirectoryPath(Path.GetFullPath(ToolsDirectory))
.WithSubDirectories(PackageId, PackageVersion);
var shimPath = Path.Combine(
ShimsDirectory,
ProjectRestorerMock.FakeCommandName +