Improve support of nuget commands with file-based apps#53535
Open
jjonescz wants to merge 16 commits intodotnet:release/10.0.3xxfrom
Open
Improve support of nuget commands with file-based apps#53535jjonescz wants to merge 16 commits intodotnet:release/10.0.3xxfrom
jjonescz wants to merge 16 commits intodotnet:release/10.0.3xxfrom
Conversation
3 tasks
Contributor
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
approved these changes
Mar 26, 2026
Contributor
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
Member
Author
|
@333fred @RikkiGibson @MiYanni for reviews, thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #49200.
Needs NuGet/NuGet.Client#7169.