Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 5, 2026

Summary

Adds "CachePlugins" feature flag to control cache plugin execution (Quickbuild, etc.) at runtime via the MSBUILD_CACHEPLUGINS_DISABLED environment 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

  • 100 existing project cache tests pass
  • 2 new tests verify flag correctly enables/disables cache plugin initialization and usage via environment variable
  • Tested graph builds, VS scenarios, and ShouldUseCache code paths

Risk

Low. Changes are defensive checks that gate existing functionality. Three guarded entry points:

  • ProjectCacheService.InitializePluginsForGraph() - graph build initialization
  • ProjectCacheService.InitializePluginsForVsScenario() - VS scenario initialization
  • ProjectCacheService.ShouldUseCache() - runtime cache queries

Feature checks MSBUILD_CACHEPLUGINS_DISABLED environment variable. When set to "1" or "true", returns FeatureStatus.NotAvailable and cache plugins are disabled. When not set or empty, returns FeatureStatus.Available (default).

Original prompt

This section details on the original issue you should resolve

<issue_title>Wrap Quickbuild with a remote feature flag to be able to disable it.</issue_title>
<issue_description>MSBuild doesn't control versioning for this Quickbuild plugging.
Wrapping this with the remote flag would give us move control if something goes wrong with this dependency.</issue_description>

Comments on the Issue (you are @copilot in this section)

@rainersigwald I'd say not "quickbuild" but "any cache plugin"

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 5, 2026 12:49
- 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 AI changed the title [WIP] Wrap cache plugin with a remote feature flag for control Add remote feature flag for cache plugins Jan 5, 2026
Copilot AI requested a review from YuliiaKovalova January 5, 2026 13:05
@YuliiaKovalova
Copy link
Member

@copilot edit it by considering how remote flags work in VS (e.g:
if (featureFlags.IsFeatureEnabled("MSBuild.VSTelemetryDisabled", false))
{
Environment.SetEnvironmentVariable("MSBUILD_TELEMETRY_OPTOUT", "1", EnvironmentVariableTarget.Process);
}
})

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]>
Copy link
Contributor Author

Copilot AI commented Jan 5, 2026

@copilot edit it by considering how remote flags work in VS (e.g:
if (featureFlags.IsFeatureEnabled("MSBuild.VSTelemetryDisabled", false))
{
...

Updated to use environment variable pattern. The feature is now controlled via MSBUILD_CACHEPLUGINS_DISABLED environment variable, which VS can set through remote feature flags. When set to "1" or "true", cache plugins are disabled. Commit db114bd.

Copilot AI changed the title Add remote feature flag for cache plugins Add remote feature flag for cache plugins via environment variable Jan 5, 2026
{
// 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")
Copy link
Member

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?

Copy link
Member

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?

Copy link
Contributor Author

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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrap Quickbuild with a remote feature flag to be able to disable it.

2 participants