Improve support of nuget commands with file-based apps#53535
Improve support of nuget commands with file-based apps#53535jjonescz merged 21 commits intodotnet:release/10.0.3xxfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Extends file-based app support to NuGet-related CLI flows by integrating a virtual project builder into NuGet XPlat execution, so dotnet package * and dotnet nuget why can operate on *.cs entrypoints and reflect package changes back into #:package directives.
Changes:
- Add an
IVirtualProjectBuilderimplementation for file-based apps and a reflector that syncs NuGet-editedPackageReferenceitems back into#:packagedirectives. - Route
dotnet package add/remove/listanddotnet nuget whythrough updated NuGet XPlat entrypoints, including in-proc execution when needed. - Update tests and remove the obsolete
DirectivesRemovedlocalized resource entry.
Reviewed changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/dotnet.Tests/CommandTests/Run/RunFileTests.cs | Adds coverage for creating a NuGet-compatible virtual project root element from a file-based app. |
| test/dotnet.Tests/CommandTests/Project/Convert/DotnetProjectConvertTests.cs | Updates call-site for new VirtualProjectBuilder.CreateProjectInstance out parameter. |
| test/dotnet.Tests/CommandTests/Package/Remove/GivenDotnetRemovePackage.cs | Updates expectations to NuGet-driven output for file-based package removal. |
| test/dotnet.Tests/CommandTests/Package/List/GivenDotnetListPackage.cs | Adds test for listing packages for a file-based app via dotnet list … package. |
| test/dotnet.Tests/CommandTests/NuGet/GivenANuGetCommand.cs | Adds file-based app coverage for nuget why and package update. |
| src/Microsoft.DotNet.ProjectTools/VirtualProjectBuilder.cs | Extends CreateProjectInstance to also return a ProjectRootElement for reuse by NuGet. |
| src/Common/EnvironmentVariableNames.cs | Adds DOTNET_HOST_PATH constant. |
| src/Cli/dotnet/Parser.cs | Passes the virtual project builder into NuGet XPlat command registration. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf | Removes DirectivesRemoved translation entry. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf | Removes DirectivesRemoved translation entry. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf | Removes DirectivesRemoved translation entry. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf | Removes DirectivesRemoved translation entry. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf | Removes DirectivesRemoved translation entry. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf | Removes DirectivesRemoved translation entry. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf | Removes DirectivesRemoved translation entry. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf | Removes DirectivesRemoved translation entry. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf | Removes DirectivesRemoved translation entry. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf | Removes DirectivesRemoved translation entry. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf | Removes DirectivesRemoved translation entry. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf | Removes DirectivesRemoved translation entry. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf | Removes DirectivesRemoved translation entry. |
| src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs | Adds NoConsoleLogger and tweaks restore/build target handling for virtual projects. |
| src/Cli/dotnet/Commands/Run/Api/RunApiCommand.cs | Updates call-site for new CreateProjectInstance out parameter ordering. |
| src/Cli/dotnet/Commands/Project/Convert/ProjectConvertCommand.cs | Updates call-site for new CreateProjectInstance out parameter. |
| src/Cli/dotnet/Commands/Package/VirtualProjectPackageReflector.cs | New: reflects NuGet PackageReference changes back into #:package directives. |
| src/Cli/dotnet/Commands/Package/Remove/PackageRemoveCommand.cs | Routes file-based removal through NuGet virtual project path instead of manual directive editing. |
| src/Cli/dotnet/Commands/Package/List/PackageListCommand.cs | Enables restore+list for file-based apps by using virtual project restore and NuGet runner selection. |
| src/Cli/dotnet/Commands/Package/Add/PackageAddCommand.cs | Routes file-based add through NuGet runner and uses virtual project build to generate restore graph when needed. |
| src/Cli/dotnet/Commands/NuGet/NuGetVirtualProjectBuilder.cs | New: implements NuGet XPlat IVirtualProjectBuilder for file-based apps. |
| src/Cli/dotnet/Commands/NuGet/NuGetCommand.cs | Adds in-proc NuGet runner selection for file-based scenarios and ensures DOTNET_HOST_PATH is set. |
| src/Cli/dotnet/Commands/CliCommandStrings.resx | Removes DirectivesRemoved resource. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/Commands/Package/PackageListCommandDefinition.cs | Adds --file/--project options to dotnet package list and aligns path parsing API. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/Commands/Hidden/List/ListReferenceCommandDefinition.cs | Updates hidden dotnet list to accept file paths via unified argument. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/Commands/Hidden/List/ListPackageCommandDefinition.cs | Updates hidden dotnet list … package to accept file paths via unified argument. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/Commands/Hidden/List/ListCommandDefinition.cs | Renames argument to “solution/project/file” to reflect new supported inputs. |
nkolev92
left a comment
There was a problem hiding this comment.
Looks fine to me, nothing stands out.
Please get an SDK reviewer here, don't just rely on my approval.
daf7b83 to
053c44f
Compare
053c44f to
5c20baa
Compare
|
@333fred @RikkiGibson @MiYanni for reviews, thanks |
RikkiGibson
left a comment
There was a problem hiding this comment.
LGTM with some minor questions/concerns.
|
@333fred for another review, thanks |
1 similar comment
|
@333fred for another review, thanks |
| builder.CreateProjectInstance( | ||
| projectCollection, | ||
| ErrorReporters.IgnoringReporter, | ||
| out _, |
There was a problem hiding this comment.
Consider using named parameters for discards like this.
|
/ba-g unrelated test failures, same as in #53759 |
Resolves #49200.
Needs NuGet/NuGet.Client#7169.