Repository navigation
Conversation
|
Since this PR is changing CI as it modifies YML files, please verify that you've addressed how this change should apply to release branches. Either:
|
cd68f6b to
c503422
Compare
5d6d1fc to
d2d8a53
Compare
nkolev92
left a comment
There was a problem hiding this comment.
Let's hide this behind a feature flag as we discussed.
* Share name@version parsing through PackageIdentity Extract the shared parser and XPlat adoption from #7771 as the bottom layer of the init-script PR stack. Co-authored-by: Copilot App <[email protected]> * Address PackageIdentity parsing API review feedback Rename ParseAtSeparated to Parse and add TryParse. Update callers, API baselines, and tests, including assertions that preserve the original version string and build metadata. Co-authored-by: Copilot App <[email protected]> * Refine PackageIdentity parsing validation and shared logic Remove package ID length enforcement from Parse and TryParse. Share separator handling through GetParts, declare the parsed version inline, and verify long IDs parse successfully. Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: Copilot App <[email protected]>
fb3f4aa to
2365d28
Compare
|
This PR is now very different to when I originally opened it. It now is just the changes for the |
There was a problem hiding this comment.
🟡 Changes recommended
Tab completion fails after the first comma-separated package selector because it matches the entire argument instead of the current element; the completion logic and a multi-package regression test are needed.
1 open issue
1 file not reviewed
src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/Resources.Designer.cs: Generated file
What changed in this PR
Adds feature-gated Get-PackageInitScript discovery to NuGet’s Package Manager Console, building on shared package-selector parsing and feature-flag infrastructure. Automatic script execution remains unchanged.
Changes:
- Discovers installed
tools/init.ps1scripts in dependency order, with deduplication and optionalid@versionselection. - Adds command export, tab completion, help, and localizable error messages.
- Adds tests for feature gating, selection, ordering, and packages.config and PackageReference discovery.
| File | Description |
|---|---|
| test/NuGet.Clients.Tests/NuGetConsole.Host.PowerShell.Test/Fixtures/CmdletRunspaceFixture.cs | Registers the cmdlet and captures script invocation errors. |
| test/NuGet.Clients.Tests/NuGetConsole.Host.PowerShell.Test/Cmdlets/PackageInitScriptCommandTests.cs | Tests discovery behavior without script execution. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/xlf/Resources.zh-Hant.xlf | Adds Traditional Chinese localization entries. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/xlf/Resources.zh-Hans.xlf | Adds Simplified Chinese localization entries. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/xlf/Resources.tr.xlf | Adds Turkish localization entries. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/xlf/Resources.ru.xlf | Adds Russian localization entries. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/xlf/Resources.pt-BR.xlf | Adds Brazilian Portuguese localization entries. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/xlf/Resources.pl.xlf | Adds Polish localization entries. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/xlf/Resources.ko.xlf | Adds Korean localization entries. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/xlf/Resources.ja.xlf | Adds Japanese localization entries. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/xlf/Resources.it.xlf | Adds Italian localization entries. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/xlf/Resources.fr.xlf | Adds French localization entries. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/xlf/Resources.es.xlf | Adds Spanish localization entries. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/xlf/Resources.de.xlf | Adds German localization entries. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/xlf/Resources.cs.xlf | Adds Czech localization entries. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/Utils/PackageInitScriptHelper.cs | Implements feature gating, discovery, and selector matching. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/Utility/NuGetErrorId.cs | Defines the unmatched-selector error identifier. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/Scripts/nuget.psm1 | Registers package-selector tab completion. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/Scripts/NuGet.psd1 | Exports the new cmdlet. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/Scripts/NuGet.PackageManagement.PowerShellCmdlets.dll-Help.xml | Documents discovery, selectors, output, and examples. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/Resources.resx | Adds feature-disabled and unmatched-selector messages. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/Resources.Designer.cs | Adds generated resource accessors. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/Model/PowerShellPackageInitScript.cs | Defines output containing package identity and script path. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/Cmdlets/GetPackageInitScriptCommand.cs | Implements the discovery cmdlet and optional selectors. |
Review effort: Balanced
d8754ba to
99e74a8
Compare
Preserve legacy initialization while the feature is disabled and exercise both flag states in Apex. Restore the original about-help and localization configuration. Co-authored-by: Copilot App <[email protected]> Copilot-Session: b0280b67-b29c-46a2-b801-e89275774e12
Defer explicit import, automatic init-script execution controls, and their lifecycle coverage to the next stack layer. Co-authored-by: Copilot App <[email protected]> Copilot-Session: b0280b67-b29c-46a2-b801-e89275774e12
List all matching installed package versions without ambiguity errors. Simplify feature-disabled wording and remove activation instructions. Clarify discovery help and regenerate resources with Dev18. Co-authored-by: Copilot App <[email protected]> Copilot-Session: b0280b67-b29c-46a2-b801-e89275774e12
Preserve preceding selectors when completing comma-separated package arguments. Handle empty completion matches and cover the shipped module with runspace tests. Co-authored-by: Copilot App <[email protected]> Copilot-Session: b0280b67-b29c-46a2-b801-e89275774e12
99e74a8 to
122e511
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Package completion fails for valid comma-and-whitespace-separated arrays because later elements are parsed as positional arguments, requiring parsing and replacement fixes plus a regression test.
1 open issue
1 resolved since last review
1 file not reviewed
src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/Resources.Designer.cs: Generated file
Review effort: Balanced
| Register-TabExpansion 'Get-PackageInitScript' @{ | ||
| 'Packages' = { |

Bug
Towards: NuGet/Home#15141
Spec: https://github.com/NuGet/Home/blob/dev/accepted/2026/control-powershell-script-execution.md
Description
Adds only
Get-PackageInitScript, the discovery portion of the PowerShell script execution spec, as layer 3 above shared name@version parsing (#7857) and feature flag infrastructure (#7858).The cmdlet lists installed solution packages' tools/init.ps1 scripts without executing them, returning package ID, version, and absolute path as FullName. It preserves solution-level dependency ordering and deduplication, supports optional package selectors (including id@version), and includes tab completion and help. The command is guarded by the default-off
NuGet.ControlPowerShellScriptExecutionfeature flag.Automatic init.ps1, install.ps1, and uninstall.ps1 execution is unchanged, even when the flag is enabled.
Import-PackageInitScriptand the changes disabling automatic initialization are deferred to a subsequent stacked PR, together with their execution and Apex lifecycle coverage.Includes discovery-only cmdlet coverage for feature gating, package selection and errors, ordering and deduplication, packages.config, and PackageReference global/fallback folders. The about-help file and localization pipeline configuration remain unchanged.
PR Checklist