Skip to content

Allow disabling runtime versions via an environment variable - #119343

Merged
elinor-fung merged 4 commits into
dotnet:mainfrom
elinor-fung:disableVersions-envVar
Sep 10, 2025
Merged

Allow disabling runtime versions via an environment variable#119343
elinor-fung merged 4 commits into
dotnet:mainfrom
elinor-fung:disableVersions-envVar

Conversation

@elinor-fung

@elinor-fung elinor-fung commented Sep 4, 2025

Copy link
Copy Markdown
Member

Allow disabling specific runtime versions during framework resolution via an environment variable

  • Read the DOTNET_DISABLE_RUNTIME_VERSIONS environment variable as one or more versions separated by semi-colons - for example, 9.0.7 or 9.0.2;9.0.7
    • Must be the exact version string. An invalid or non-existent version has no effect.
    • Resolver reads and stores this when it is created
  • Update the framework resolution logic to skip disabled versions when searching for compatible frameworks
    • If all matching versions are disabled, resolution fails

Resolves #118553

cc @dotnet/appmodel @AaronRobinsonMSFT

Copilot AI review requested due to automatic review settings September 4, 2025 04:54
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements functionality to allow disabling specific runtime versions during framework resolution via the DOTNET_DISABLE_RUNTIME_VERSIONS environment variable. The feature enables users to prevent the framework resolver from selecting specified versions, even if they would normally be chosen through roll-forward logic.

Key changes:

  • Added environment variable parsing for semicolon-separated disabled versions
  • Modified framework resolution logic to skip disabled versions during search
  • Added comprehensive test coverage for various disable scenarios

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/native/corehost/fxr/fx_resolver.h Moved constructor to implementation file and added member variable for disabled versions
src/native/corehost/fxr/fx_resolver.cpp Implemented environment variable parsing, constructor, and disabled version checking in resolution logic
src/installer/tests/TestUtils/Constants.cs Added constant for the new environment variable name
src/installer/tests/HostActivation.Tests/FrameworkResolution/FrameworkResolution.cs Added comprehensive test cases covering single/multiple disabled versions and roll-forward scenarios

Comment thread src/native/corehost/fxr/fx_resolver.cpp Outdated
Comment thread src/native/corehost/fxr/fx_resolver.cpp
Comment thread src/native/corehost/fxr/fx_resolver.cpp
Comment thread src/native/corehost/fxr/fx_resolver.h
Comment thread src/native/corehost/fxr/fx_resolver.cpp
@elinor-fung
elinor-fung merged commit cecdae6 into dotnet:main Sep 10, 2025
153 checks passed
@elinor-fung
elinor-fung deleted the disableVersions-envVar branch September 10, 2025 02:20
@elinor-fung

Copy link
Copy Markdown
Member Author

/backport to release/10.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/10.0: https://github.com/dotnet/runtime/actions/runs/17601140737

@github-actions

Copy link
Copy Markdown
Contributor

@elinor-fung backporting to "release/10.0" failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Allow disabling runtime versions via an environment variable
Applying: Update get_all_framework_infos, add test cases
.git/rebase-apply/patch:35: trailing whitespace.
            { 
warning: 1 line adds whitespace errors.
Using index info to reconstruct a base tree...
M	src/installer/tests/HostActivation.Tests/NativeHostApis.cs
Falling back to patching base and 3-way merge...
Auto-merging src/installer/tests/HostActivation.Tests/NativeHostApis.cs
CONFLICT (content): Merge conflict in src/installer/tests/HostActivation.Tests/NativeHostApis.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0002 Update get_all_framework_infos, add test cases
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

elinor-fung added a commit to elinor-fung/runtime that referenced this pull request Sep 10, 2025
…119343)

- Read the `DOTNET_DISABLE_RUNTIME_VERSIONS` environment variable as one or more versions separated by semi-colons - for example, `9.0.7` or `9.0.2;9.0.7`
  - Must be the exact version string. An invalid or non-existent version has no effect.
  - Resolver reads and stores this when it is created
- Update the framework resolution logic to skip disabled versions when searching for compatible frameworks
  - If all matching versions are disabled, resolution fails
agocke pushed a commit that referenced this pull request Sep 22, 2025
#119518)

- Read the `DOTNET_DISABLE_RUNTIME_VERSIONS` environment variable as one or more versions separated by semi-colons - for example, `9.0.7` or `9.0.2;9.0.7`
  - Must be the exact version string. An invalid or non-existent version has no effect.
  - Resolver reads and stores this when it is created
- Update the framework resolution logic to skip disabled versions when searching for compatible frameworks
  - If all matching versions are disabled, resolution fails
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature for disabling specific runtimes

3 participants