diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectToolsCommandResolver.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectToolsCommandResolver.cs index b4edd7583..e0f4ea3ef 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectToolsCommandResolver.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectToolsCommandResolver.cs @@ -201,9 +201,24 @@ namespace Microsoft.DotNet.Cli.Utils yield return packageFolder.Path; } } + } - var nuGetPathContext = NuGetPathContext.Create(project.ProjectRoot); - yield return nuGetPathContext.UserPackageFolder; + private LockFile GetToolLockFile( + SingleProjectInfo toolLibrary, + IEnumerable 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( @@ -233,21 +248,6 @@ namespace Microsoft.DotNet.Cli.Utils return true; } - private LockFile GetToolLockFile(SingleProjectInfo toolLibrary, IEnumerable 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( SingleProjectInfo toolLibrary, string nugetPackagesRoot) diff --git a/test/dotnet.Tests/PackagedCommandTests.cs b/test/dotnet.Tests/PackagedCommandTests.cs index 236a30096..b08cc2eeb 100644 --- a/test/dotnet.Tests/PackagedCommandTests.cs +++ b/test/dotnet.Tests/PackagedCommandTests.cs @@ -138,7 +138,7 @@ namespace Microsoft.DotNet.Tests .WithWorkingDirectory(testInstance.Root) .ExecuteWithCapturedOutput("nonexistingtool") .Should().Fail() - .And.HaveStdErrContaining("Version for package `dotnet-nonexistingtool` could not be resolved."); + .And.HaveStdErrContaining("No executable found matching command \"dotnet-nonexistingtool\""); } [Fact]