Repository navigation
Add PowerShell script execution feature flag infrastructure - #7858
Merged
Merged
Conversation
jebriede
reviewed
Nov 10, 2026
jebriede
previously approved these changes
Nov 10, 2026
Base automatically changed from
dev-zivkan-package-identity-shared-code
to
dev
November 16, 2026 20:08
zivkan
force-pushed
the
dev-zivkan-feature-flag-infrastructure
branch
from
November 17, 2026 00:27
48c777e to
61d2dce
Compare
Nigusu-Allehu
self-requested a review
November 17, 2026 23:51
nkolev92
reviewed
Nov 18, 2026
jebriede
reviewed
Nov 18, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Loading NuGetPackage alone no longer initializes the feature flags, and changing the serializer switch mid-connection can cause queued plugin payload decoding to throw InvalidCastException.
2 open issues
What changed in this PR
Adds default-off PowerShell script-execution feature-flag infrastructure for future NuGet behavior changes. It bridges Visual Studio flag resolution to core libraries through AppContext, without yet changing automatic script execution.
Changes:
- Defines the PowerShell flag and environment override, with shared asynchronous initialization.
- Adds initialization guards to solution-manager and PowerShell-host entry points and makes JSON-switch reads dynamic.
- Adds tests for switch changes, override precedence, shared initialization, and failure handling.
| File | Description |
|---|---|
| test/NuGet.Core.Tests/NuGet.Protocol.Tests/NuGetFeatureFlagsTests.cs | Tests dynamic JSON-switch reads. |
| test/NuGet.Core.Tests/NuGet.PackageManagement.Test/NuGetFeatureFlagsTests.cs | Tests PowerShell flag overrides and switch changes. |
| test/NuGet.Clients.Tests/NuGetConsole.Host.PowerShell.Test/PowerShellHostTests.cs | Tests initialization waiting and failure handling. |
| test/NuGet.Clients.Tests/NuGet.VisualStudio.Common.Test/NuGetFeatureFlagInitializerTests.cs | Tests switch publication and shared initialization. |
| test/NuGet.Clients.Tests/NuGet.PackageManagement.VisualStudio.Test/VSSolutionManagerTest.cs | Tests initialization gating and failure propagation. |
| src/NuGet.Core/NuGet.PackageManagement/NuGet.PackageManagement.csproj | Includes shared flag and compatibility helpers. |
| src/NuGet.Clients/NuGet.VisualStudio.Common/Services/NuGetFeatureFlagInitializer.cs | Adds shared asynchronous switch publication. |
| src/NuGet.Clients/NuGet.VisualStudio.Common/Services/NuGetFeatureFlagConstants.cs | Defines the default-off PowerShell flag. |
| src/NuGet.Clients/NuGet.VisualStudio.Common/Services/INuGetFeatureFlagInitializer.cs | Defines the initialization contract. |
| src/NuGet.Clients/NuGet.Tools/NuGetPackage.cs | Removes direct JSON-switch publication. |
| src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/IDE/VSSolutionManager.cs | Awaits flags before project initialization. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/PowerShellHost.cs | Awaits flags before host initialization. |
| src/NuGet.Clients/NuGet.PackageManagement.PowerShellCmdlets/NuGet.PackageManagement.PowerShellCmdlets.csproj | Includes shared flag and compatibility helpers. |
| build/Shared/NuGetFeatureFlags.cs | Adds PowerShell flag reads and dynamic JSON-switch access. |
Review effort: Balanced
nkolev92
approved these changes
Nov 18, 2026
Extract the default-off VS feature flag and shared AppContext bridge for the next init-script layer, without changing script execution behavior. Co-authored-by: Copilot App <[email protected]>
Inject the environment reader, remove redundant cases, and isolate switch refresh coverage. Use the shared environment variable constant consistently and keep the feature guide general. Co-authored-by: Copilot App <[email protected]>
Gate solution manager and PowerShell host initialization on a shared, one-time initializer for feature flags and experiments, independent of NuGetPackage load order. Move System.Text.Json experiment publication into shared initialization and read its AppContext switch dynamically to avoid caching an early value. Add focused regression coverage and document shared initialization. Co-authored-by: Copilot App <[email protected]>
Move AppContext switch publication into a dedicated initializer that coordinates feature flags and experiments. Keep the query services independent and update solution manager and PowerShell host gates. Consolidate shared flag readers into NuGetFeatureFlags, preserving environment override behavior and isolating the JSON cache. Move initialization guidance from the feature guide to service comments and relocate the focused regression tests. Co-authored-by: Copilot App <[email protected]>
Keep JSON serializer selection cached and initialize shared flags during NuGetPackage initialization, retaining the solution-manager and PMC gates. Log lookup failures without blocking NuGet operations or retrying until VS restarts. Move solution-manager initialization inside its try/catch and after the initialized check. Co-authored-by: Copilot App <[email protected]>
zivkan
force-pushed
the
dev-zivkan-feature-flag-infrastructure
branch
from
November 20, 2026 03:29
f35ce44 to
2ba051a
Compare
zivkan
enabled stacked auto-merge (squash)
November 20, 2026 03:30
This was referenced Nov 20, 2026
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.

Bug
Towards: NuGet/Home#15141
Description
Extracts the feature-flag infrastructure from #7771 as a smaller PR to review. This PR doesn't change any functionality, just puts the feature flag in place, for later PRs to use.
Registers the native Visual Studio flag
NuGet.ControlPowerShellScriptExecution, defaulting to off, and publishes its resolved value throughAppContextduring NuGet package initialization. This allows NuGet "core" libraries that can't use the VSSDK, to be able to read the flag value and change behavior.PR Checklist
Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.N/A