remove redundant packagesRoot path check and reorder methods
This commit is contained in:
parent
444dd6a031
commit
aa7fb60d73
2 changed files with 18 additions and 18 deletions
|
@ -201,9 +201,24 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
yield return packageFolder.Path;
|
yield return packageFolder.Path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var nuGetPathContext = NuGetPathContext.Create(project.ProjectRoot);
|
private LockFile GetToolLockFile(
|
||||||
yield return nuGetPathContext.UserPackageFolder;
|
SingleProjectInfo toolLibrary,
|
||||||
|
IEnumerable<string> possibleNugetPackagesRoot,
|
||||||
|
out string nugetPackagesRoot)
|
||||||
|
{
|
||||||
|
foreach (var packagesRoot in possibleNugetPackagesRoot)
|
||||||
|
{
|
||||||
|
if (TryGetToolLockFile(toolLibrary, packagesRoot, out LockFile lockFile))
|
||||||
|
{
|
||||||
|
nugetPackagesRoot = packagesRoot;
|
||||||
|
return lockFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nugetPackagesRoot = null;
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool TryGetToolLockFile(
|
private bool TryGetToolLockFile(
|
||||||
|
@ -233,21 +248,6 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private LockFile GetToolLockFile(SingleProjectInfo toolLibrary, IEnumerable<string> possibleNugetPackagesRoot, out string nugetPackagesRoot)
|
|
||||||
{
|
|
||||||
foreach (var packagesRoot in possibleNugetPackagesRoot)
|
|
||||||
{
|
|
||||||
if (TryGetToolLockFile(toolLibrary, packagesRoot, out LockFile lockFile))
|
|
||||||
{
|
|
||||||
nugetPackagesRoot = packagesRoot;
|
|
||||||
return lockFile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nugetPackagesRoot = null;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GetToolLockFilePath(
|
private string GetToolLockFilePath(
|
||||||
SingleProjectInfo toolLibrary,
|
SingleProjectInfo toolLibrary,
|
||||||
string nugetPackagesRoot)
|
string nugetPackagesRoot)
|
||||||
|
|
|
@ -138,7 +138,7 @@ namespace Microsoft.DotNet.Tests
|
||||||
.WithWorkingDirectory(testInstance.Root)
|
.WithWorkingDirectory(testInstance.Root)
|
||||||
.ExecuteWithCapturedOutput("nonexistingtool")
|
.ExecuteWithCapturedOutput("nonexistingtool")
|
||||||
.Should().Fail()
|
.Should().Fail()
|
||||||
.And.HaveStdErrContaining("Version for package `dotnet-nonexistingtool` could not be resolved.");
|
.And.HaveStdErrContaining("No executable found matching command \"dotnet-nonexistingtool\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue