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)
|
public ToolPackageStore(DirectoryPath root)
|
||||||
{
|
{
|
||||||
Root = root;
|
Root = new DirectoryPath(Path.GetFullPath(root.Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public DirectoryPath Root { get; private set; }
|
public DirectoryPath Root { get; private set; }
|
||||||
|
|
|
@ -685,7 +685,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests
|
||||||
FilePath? tempProject = null,
|
FilePath? tempProject = null,
|
||||||
DirectoryPath? offlineFeed = 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();
|
var reporter = new BufferedReporter();
|
||||||
|
|
||||||
IFileSystem fileSystem;
|
IFileSystem fileSystem;
|
||||||
|
@ -714,6 +714,8 @@ namespace Microsoft.DotNet.ToolPackage.Tests
|
||||||
offlineFeed: offlineFeed ?? new DirectoryPath("does not exist"));
|
offlineFeed: offlineFeed ?? new DirectoryPath("does not exist"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
store.Root.Value.Should().Be(Path.GetFullPath(root.Value));
|
||||||
|
|
||||||
return (store, installer, reporter, fileSystem);
|
return (store, installer, reporter, fileSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks
|
||||||
IFileSystem fileSystem,
|
IFileSystem fileSystem,
|
||||||
Action uninstallCallback = null)
|
Action uninstallCallback = null)
|
||||||
{
|
{
|
||||||
Root = root;
|
Root = new DirectoryPath(Path.GetFullPath(root.Value));
|
||||||
_fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
|
_fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
|
||||||
_uninstallCallback = uninstallCallback;
|
_uninstallCallback = uninstallCallback;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,8 @@ namespace Microsoft.DotNet.Tests.Commands
|
||||||
PackageId,
|
PackageId,
|
||||||
PackageVersion));
|
PackageVersion));
|
||||||
|
|
||||||
var packageDirectory = new DirectoryPath(ToolsDirectory).WithSubDirectories(PackageId, PackageVersion);
|
var packageDirectory = new DirectoryPath(Path.GetFullPath(ToolsDirectory))
|
||||||
|
.WithSubDirectories(PackageId, PackageVersion);
|
||||||
var shimPath = Path.Combine(
|
var shimPath = Path.Combine(
|
||||||
ShimsDirectory,
|
ShimsDirectory,
|
||||||
ProjectRestorerMock.FakeCommandName +
|
ProjectRestorerMock.FakeCommandName +
|
||||||
|
@ -114,7 +115,8 @@ namespace Microsoft.DotNet.Tests.Commands
|
||||||
PackageId,
|
PackageId,
|
||||||
PackageVersion));
|
PackageVersion));
|
||||||
|
|
||||||
var packageDirectory = new DirectoryPath(ToolsDirectory).WithSubDirectories(PackageId, PackageVersion);
|
var packageDirectory = new DirectoryPath(Path.GetFullPath(ToolsDirectory))
|
||||||
|
.WithSubDirectories(PackageId, PackageVersion);
|
||||||
var shimPath = Path.Combine(
|
var shimPath = Path.Combine(
|
||||||
ShimsDirectory,
|
ShimsDirectory,
|
||||||
ProjectRestorerMock.FakeCommandName +
|
ProjectRestorerMock.FakeCommandName +
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue