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:
parent
cee0a3baa7
commit
4f8ac7dce5
4 changed files with 9 additions and 5 deletions
|
@ -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; }
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 +
|
||||
|
|
Loading…
Reference in a new issue