Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Implement roll-forward policies for .NET Core SDK resolution. #6953

Merged
merged 5 commits into from
Jul 10, 2019

Conversation

peterhuene
Copy link

@peterhuene peterhuene commented Jun 27, 2019

This PR implements additional roll-forward policies for resolving a .NET
Core SDK based upon new SDK settings in global.json.

Two new values are now supported in global.json in the sdk settings:

  • rollForward - the roll-forward policy to use (see below).
  • allowPrerelease - controls whether or not preview SDKS may be resolved
    (defaults to true to allow resolving prerelease SDKs).

The new roll-forward policies are:

  • patch - If the requested SDK is installed, use it. Otherwise, use the
    latest installed patch level that matches the requested major, minor, and
    feature band.
  • feature - If the requested major, minor, and feature band is installed, use
    the latest patch level for the specified feature band. Otherwise, roll-forward
    to the next available feature band and use the latest patch level for that
    feature band.
  • minor - If the requested major, minor, and feature band is installed, use
    the latest patch level for the specified feature band. Otherwise, roll-forward
    to the next available feature band available for the same major version and use
    the latest patch level for that feature band.
  • major - If the requested major, minor, and feature band is installed, use
    the latest patch level for the specified feature band. Otherwise, roll-forward
    to the next available feature band available without restriction and use the
    latest patch level for that feature band.
  • latestPatch - Use the latest installed patch level that matches the
    requested major, minor, and feature band.
  • latestFeature - Use the latest installed patch level for the latest
    installed feature band that matches the requested major and minor version.
  • latestMinor - Use the latest installed patch level for the latest installed
    feature band for the latest installed minor version that matches the requested
    major version.
  • latestMajor - Use the absolutely latest .NET Core SDK available.

For backwards compatibility, the policy when a version is not specified in
global.json will be latestMajor. The default policy when a version is
specified but rollForward is not specified will be patch.

@peterhuene
Copy link
Author

See design document for more information on this feature.

This commit implements additional roll-forward policies for resolving a .NET
Core SDK based upon new SDK settings in `global.json`.

Two new values are now supported in `global.json` in the `sdk` settings:

* `rollForward` - the roll-forward policy to use (see below).
* `allowPrerelease` - controls whether or not preview SDKS may be resolved.

The new roll-forward policies are:

* `patch` - If the requested SDK is installed, use it. Otherwise, use the
  latest installed patch level that matches the requested major, minor, and
  feature band.
* `feature` - If the requested major, minor, and feature band is installed, use
the latest patch level for the specified feature band.  Otherwise, roll-forward
to the next available feature band and use the latest patch level for that
feature band.
* `minor` - If the requested major, minor, and feature band is installed, use
the latest patch level for the specified feature band.  Otherwise, roll-forward
to the next available feature band available for the same major version and use
the latest patch level for that feature band.
* `major` - If the requested major, minor, and feature band is installed, use
the latest patch level for the specified feature band.  Otherwise, roll-forward
to the next available feature band available without restriction and use the
latest patch level for that feature band.
* `latestPatch` - Use the latest installed patch level that matches the
requested major, minor, and feature band.
* `latestFeature` - Use the latest installed patch level for the latest
installed feature band that matches the requested major and minor version.
* `latestMinor` - Use the latest installed patch level for the latest installed
feature band for the latest installed minor version that matches the requested
major version.
* `latestMajor` - Use the absolutely latest .NET Core SDK available.

For backwards compatibility, the policy when a `version` is not specified in
`global.json` will be `latestMajor`.  The default policy when a `version` is
specified but `rollForward` is not specified will be `patch`.
@peterhuene peterhuene force-pushed the global-json-sdk-improvements branch from 3a97deb to 763475d Compare June 27, 2019 02:58
@nguerrera
Copy link

The default policy when a version is
specified but rollForward is not specified will be patch.

I thought we agreed to change this to major.

@peterhuene
Copy link
Author

I wasn't sure if that was now captured in the design document, but you're right. It's easy to change and update the tests. I'll push that up and we can fix any language needed in the doc.

@peterhuene
Copy link
Author

We're going to discuss changing the default when just a version is specified from patch to major later today, as Kathleen has raised some concerns. If we do decide to change the default, I'll push up that change at that time. Until then, this can be reviewed with no change in the existing behavior.

@peterhuene
Copy link
Author

We've decided not to change the default behavior when a version is specified without rollForward policy in global.json. The default will remain as patch for now. Thus, these changes should not introduce any breaking changes for now.

@peterhuene peterhuene force-pushed the global-json-sdk-improvements branch from b603438 to 4ec4e34 Compare June 29, 2019 09:24
This commit makes the policy names for the `sdk/rollForward` value in
`global.json` case insensitive.

It also removes the switch statements used in parsing / displaying the roll
forward policy names in favor of a constant array of names indexed by the enum
value.
@peterhuene peterhuene force-pushed the global-json-sdk-improvements branch 2 times, most recently from 28590b5 to 79ba75f Compare June 30, 2019 02:34
Peter Huene added 2 commits June 30, 2019 22:25
* Removed unused members from `sdk_resolver`.
* Remove unnecessary logging relating to BOMs.
* Change to warnings instead of errors when failing to parse global.json (we
fallback to "use latest" behavior).
* Use JSON names in logging for values read in from global.json.
* Remove underscore prefix from member variables.
* Make `matches_policy` and `is_better_match` less redundant in the checks
performed.
* Rename `exact_match_allowed` to `exact_match_preferred`.
* Fix whitespace in test.
This commit "theorizes" the invalid global.json test to eliminate duplicated
code.
Copy link

@nguerrera nguerrera left a comment

Choose a reason for hiding this comment

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

:shipit:

Copy link
Member

@vitek-karas vitek-karas left a comment

Choose a reason for hiding this comment

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

:shipit: assuming we have all the right approvals - even though in theory this should not be a breaking change, it's large enough to be treated similarly (especially since our test coverage is somewhat sparse and so it's hard to prove with reasonable confidence that this won't break anything).

This commit turns the JSON parsing failure back to an error for backwards
compatibility.  The new diagnostic messages remain as warnings.
@livarcocc
Copy link

This has been approved by Steve already. I gave him a heads up on this change a few weeks ago. Feel free to merge.

Also, just noticed the comment does not say what is the default for allowPrerelease. Should we state that in the description for the PR?

@peterhuene
Copy link
Author

I'll update the PR description to include that information.

@peterhuene
Copy link
Author

Oh right, I don't have access to merge 😄.

@TheXenocide
Copy link

Is it possible to use these settings on items in the msbuild-sdks section? With NuGet we would use wildcard versions, but it doesn't seem to accept anything of the sort

picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…/core-setup#6953)

Implements additional roll-forward policies for resolving a .NET
Core SDK based upon new SDK settings in `global.json`.

Two new values are now supported in `global.json` in the `sdk` settings:

* `rollForward` - the roll-forward policy to use (see below).
* `allowPrerelease` - controls whether or not preview SDKS may be resolved
(defaults to `true` to allow resolving prerelease SDKs).  


The new roll-forward policies are:

* `patch` - If the requested SDK is installed, use it. Otherwise, use the
  latest installed patch level that matches the requested major, minor, and
  feature band.
* `feature` - If the requested major, minor, and feature band is installed, use
the latest patch level for the specified feature band.  Otherwise, roll-forward
to the next available feature band and use the latest patch level for that
feature band.
* `minor` - If the requested major, minor, and feature band is installed, use
the latest patch level for the specified feature band.  Otherwise, roll-forward
to the next available feature band available for the same major version and use
the latest patch level for that feature band.
* `major` - If the requested major, minor, and feature band is installed, use
the latest patch level for the specified feature band.  Otherwise, roll-forward
to the next available feature band available without restriction and use the
latest patch level for that feature band.
* `latestPatch` - Use the latest installed patch level that matches the
requested major, minor, and feature band.
* `latestFeature` - Use the latest installed patch level for the latest
installed feature band that matches the requested major and minor version.
* `latestMinor` - Use the latest installed patch level for the latest installed
feature band for the latest installed minor version that matches the requested
major version.
* `latestMajor` - Use the absolutely latest .NET Core SDK available.

For backwards compatibility, the policy when a `version` is not specified in
`global.json` will be `latestMajor`.  The default policy when a `version` is
specified but `rollForward` is not specified will be `patch`.

Commit migrated from dotnet/core-setup@5cd0245
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants