-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Download tool packages from NuGet feeds directly, instead of implicitly restoring #33835
Conversation
81bacd3
to
08c6a31
Compare
/azp run |
Pull request contains merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job getting this working!
Some of this is pretty complicated to review, I took a first pass and added my comments, but I will probably have to look at it again later.
Thanks!
src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallGlobalOrToolPathCommand.cs
Show resolved
Hide resolved
src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallLocalInstaller.cs
Outdated
Show resolved
Hide resolved
This implementation must consider PackageSourceMapping. We're moving away from an implementation that considers it, we must not lose that. I'll review in more detail later. |
@nkolev92 @zivkan We're using NuGet APIs to download a package. The code for that is here. Is there a way to respect package source mapping when calling those APIs? |
Yeah, I'll link examples later when I review it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking pretty good, great job!
src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs
Outdated
Show resolved
Hide resolved
That's a great catch! I think that should be added as well. |
We want to have a consistent experience everywhere we can. Since most of that is implemented at restore, could we somehow provide a central API or similar piping for NuGet APIs as well? That way it is rather easy for people to contribute these types of changes without having to know about all the NuGet best security practices and years of work going into restore security? |
http warnings, PSM, signature verification are concerns at different parts of restore, so they're not really implemented at the same level. Adding a central API end up being something that's not used anywhere within the NuGet code itself, so we wouldn't know how to best author it. @zivkan mentioned this in a side-chat, but I think this is showing that we need to add some tests testing NuGet scenarios within in this repo, regardless of how stuff gets implemented :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still want to take a look at the tests, but I think I've reviewed everything else in detail now.
Let's take a look at the feedback together.
src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallLocalInstaller.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've finished reviewing the tests now too. Some of the feedback here we've already discussed live.
I also think we should add tests for some scenarios where the package has already been downloaded or the tool has already been installed in another local tools folder.
src/Tests/Microsoft.DotNet.PackageInstall.Tests/NuGetPackageInstallerTests.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs
Outdated
Show resolved
Hide resolved
packageSourceMapping: mockPackageSourceMapping).GetAwaiter().GetResult(); | ||
a.Should().Throw<NuGetPackageInstallerException>().And.Message.Should().Contain(string.Format(Cli.NuGetPackageDownloader.LocalizableStrings.FailedToGetPackageUnderPackageSourceMapping, TestPackageId)); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should have a test where package source mapping is configured correctly, and verify that it can download successfully. I'm not sure yet what the best way to write such a test would be.
src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallGlobalOrToolPathCommand.cs
Show resolved
Hide resolved
…ID>\<Package Version>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! We're almost there, just a few remaining comments.
NuGetv3LocalRepository localRepository = new(toolDownloadDir.Value); | ||
var package = localRepository.FindPackage(packageId.ToString(), packageVersion); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only applies to local tools. So I tihnk it should probably be in a block that only applies to local tools (such as an else
statement from the previous suggestion).
src/Tests/Microsoft.DotNet.PackageInstall.Tests/ToolPackageDownloaderTests.cs
Show resolved
Hide resolved
src/Tests/Microsoft.DotNet.PackageInstall.Tests/ToolPackageDownloaderTests.cs
Outdated
Show resolved
Hide resolved
…fine tests in ToolPackageDownloaderTests
78dd94c
to
38ee802
Compare
PR for issue #31134
Currently, when installing a dotnet tool package, the code restores a temporary project using
toolPackageInstaller
. This PR updated the methods handling tools to use NuGet API when installing, updating, restoring, and uninstalling global and local tools.This PR also changes the tests that test the installing, updating, restoring, and uninstalling global and local tools. It also controls the verbosity output from NuGet API when downloading tools.