mirror of
https://github.com/actions/setup-dotnet.git
synced 2026-12-01 00:43:08 +00:00
Resolve global.json latestMajor to the newest active release instead of LTS (#803)
* Resolve global.json latestMajor to the newest active release, not LTS rollForward: latestMajor cleared the version, which createChannelArgument mapped to the LTS channel. When the declared sdk.version belongs to an STS release, the LTS channel is older than the declared version and the installed SDK does not satisfy global.json. Resolve it from the releases index to the newest active release of either support type, still GA only. * Limit latestMajor resolution to global.json and enforce the minimum version An empty version without rollForward latestMajor (for example a global.json without sdk.version) resolves to the LTS channel again. After an online install, the action fails if the installed SDK is older than the global.json minimum version. The installer tests now mock the releases index instead of calling the live service.
This commit is contained in:
25
dist/setup/index.js
vendored
25
dist/setup/index.js
vendored
@@ -43980,11 +43980,13 @@ function channelForMajor(major) {
|
||||
class DotnetVersionResolver {
|
||||
quality;
|
||||
dotnetChannel;
|
||||
rollForward;
|
||||
inputVersion;
|
||||
resolvedArgument;
|
||||
constructor(version, quality = '', dotnetChannel) {
|
||||
constructor(version, quality = '', dotnetChannel, rollForward) {
|
||||
this.quality = quality;
|
||||
this.dotnetChannel = dotnetChannel;
|
||||
this.rollForward = rollForward;
|
||||
this.inputVersion = version.trim();
|
||||
this.resolvedArgument = { type: '', value: '', qualityFlag: false };
|
||||
}
|
||||
@@ -44018,6 +44020,12 @@ class DotnetVersionResolver {
|
||||
latestChannelMajorTag >= QUALITY_INPUT_MINIMAL_MAJOR_TAG;
|
||||
return;
|
||||
}
|
||||
if (this.inputVersion === '' && this.rollForward === 'latestMajor') {
|
||||
// global.json latestMajor: newest GA release, LTS or STS
|
||||
this.resolvedArgument.type = 'channel';
|
||||
this.resolvedArgument.value = await this.getLatestVersion('', '');
|
||||
return;
|
||||
}
|
||||
if (this.dotnetChannel) {
|
||||
warning(`The 'dotnet-channel' input is only supported when 'dotnet-version' is set to 'latest'.`);
|
||||
}
|
||||
@@ -44080,7 +44088,7 @@ class DotnetVersionResolver {
|
||||
}
|
||||
return this.resolvedArgument;
|
||||
}
|
||||
async getLatestVersion(channelFilter) {
|
||||
async getLatestVersion(channelFilter, quality = this.quality) {
|
||||
const httpClient = new lib_HttpClient('actions/setup-dotnet', [], {
|
||||
allowRetries: true,
|
||||
maxRetries: 3
|
||||
@@ -44096,7 +44104,7 @@ class DotnetVersionResolver {
|
||||
releasesInfo = releasesInfo.filter(info => info['support-phase'] !== 'eol');
|
||||
// Filter out preview versions if quality is not 'preview' or 'daily'
|
||||
// If quality is not specified, we assume strict stability (GA only)
|
||||
const normalizedQuality = (this.quality || '').toLowerCase();
|
||||
const normalizedQuality = (quality || '').toLowerCase();
|
||||
if (!['preview', 'daily'].includes(normalizedQuality)) {
|
||||
releasesInfo = releasesInfo.filter(info => info['support-phase'] !== 'preview');
|
||||
}
|
||||
@@ -44584,7 +44592,7 @@ class DotnetCoreInstaller {
|
||||
}
|
||||
info(`'check-latest' is false but no locally installed .NET SDK satisfies the '${this.version}' request. Falling back to online installation.`);
|
||||
}
|
||||
const versionResolver = new DotnetVersionResolver(this.version, this.quality, this.dotnetChannel);
|
||||
const versionResolver = new DotnetVersionResolver(this.version, this.quality, this.dotnetChannel, this.rollForward);
|
||||
const dotnetVersion = await versionResolver.createDotnetVersion();
|
||||
const architectureArguments = isCrossArch
|
||||
? [
|
||||
@@ -44636,7 +44644,14 @@ class DotnetCoreInstaller {
|
||||
if (dotnetInstallOutput.exitCode) {
|
||||
throw new Error(`Failed to install dotnet, exit code: ${dotnetInstallOutput.exitCode}. ${dotnetInstallOutput.stderr}`);
|
||||
}
|
||||
return this.parseInstalledVersion(dotnetInstallOutput.stdout);
|
||||
const installedVersion = this.parseInstalledVersion(dotnetInstallOutput.stdout);
|
||||
if (installedVersion &&
|
||||
this.minimumVersion &&
|
||||
semver_default().valid(installedVersion) &&
|
||||
semver_default().lt(installedVersion, this.minimumVersion)) {
|
||||
throw new Error(`The installed .NET SDK ${installedVersion} is older than the global.json minimum version ${this.minimumVersion}.`);
|
||||
}
|
||||
return installedVersion;
|
||||
}
|
||||
async installRuntime() {
|
||||
this.validateRuntimeVersion();
|
||||
|
||||
Reference in New Issue
Block a user