-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add remote feature flag for cache plugins via environment variable #12974
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
Conversation
- Add "CachePlugins" feature flag in Features.cs (enabled by default) - Add test helper methods to set/reset feature status for testing - Modify ProjectCacheService.ShouldUseCache to check feature flag - Add tests to verify cache is disabled when feature flag is NotAvailable - Add tests to verify cache is enabled when feature flag is Available Co-authored-by: YuliiaKovalova <[email protected]>
- Add feature flag check in InitializePluginsForGraph - Add feature flag check in InitializePluginsForVsScenario - Fix accidentally changed test expectation (B=1 not B=2) - All 100 project cache tests now passing Co-authored-by: YuliiaKovalova <[email protected]>
- Keep _featureStatusMap as readonly for safety - Extract default feature map to CreateDefaultFeatureStatusMap method - Avoid duplication between initialization and reset - Use Clear() and re-populate in ResetFeatureStatusForTests - All tests still passing Co-authored-by: YuliiaKovalova <[email protected]>
|
@copilot edit it by considering how remote flags work in VS (e.g: it should go through env variable setup |
- Changed from static dictionary to environment variable check (MSBUILD_CACHEPLUGINS_DISABLED) - VS can now control the feature via remote flag by setting the environment variable - Updated tests to use environment variable instead of SetFeatureAvailability - Follows the same pattern as other MSBuild features like MSBUILD_TELEMETRY_OPTOUT - All 100 project cache tests pass Co-authored-by: YuliiaKovalova <[email protected]>
Updated to use environment variable pattern. The feature is now controlled via |
| { | ||
| // Special handling for CachePlugins feature - controlled via environment variable | ||
| // This allows remote feature flags in VS to disable cache plugins by setting the environment variable | ||
| if (featureName == "CachePlugins") |
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.
why it's not a part of CreateDefaultFeatureStatusMap?
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.
@copilot why it's not a part of CreateDefaultFeatureStatusMap?
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.
The CachePlugins feature needs to check the MSBUILD_CACHEPLUGINS_DISABLED environment variable at runtime, which is different from other features that have static values in the map. The environment variable approach allows VS to dynamically control the feature through remote flags by setting the env var before MSBuild starts, following the same pattern as MSBUILD_TELEMETRY_OPTOUT. If we put it in CreateDefaultFeatureStatusMap(), it would only check the env var once at initialization, rather than on each call to CheckFeatureAvailability().
Summary
Adds "CachePlugins" feature flag to control cache plugin execution (Quickbuild, etc.) at runtime via the
MSBUILD_CACHEPLUGINS_DISABLEDenvironment variable. Enabled by default for backward compatibility, can be remotely disabled by Visual Studio if plugin issues arise.Customer Impact
Provides kill switch for cache plugins when MSBuild cannot control their versioning. VS can use remote feature flags to set the environment variable and disable cache plugins. No impact when enabled (default state). When disabled, builds proceed without caching.
Regression?
No. Feature enabled by default maintains existing behavior.
Testing
Risk
Low. Changes are defensive checks that gate existing functionality. Three guarded entry points:
ProjectCacheService.InitializePluginsForGraph()- graph build initializationProjectCacheService.InitializePluginsForVsScenario()- VS scenario initializationProjectCacheService.ShouldUseCache()- runtime cache queriesFeature checks
MSBUILD_CACHEPLUGINS_DISABLEDenvironment variable. When set to "1" or "true", returnsFeatureStatus.NotAvailableand cache plugins are disabled. When not set or empty, returnsFeatureStatus.Available(default).Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.