mirror of
https://github.com/actions/setup-dotnet.git
synced 2026-12-06 05:54:41 +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:
+30
-5
@@ -78,7 +78,8 @@ export class DotnetVersionResolver {
|
||||
constructor(
|
||||
version: string,
|
||||
private quality: QualityOptions = '',
|
||||
private dotnetChannel?: string
|
||||
private dotnetChannel?: string,
|
||||
private rollForward?: string
|
||||
) {
|
||||
this.inputVersion = version.trim();
|
||||
this.resolvedArgument = {type: '', value: '', qualityFlag: false};
|
||||
@@ -118,6 +119,13 @@ export class DotnetVersionResolver {
|
||||
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) {
|
||||
core.warning(
|
||||
`The 'dotnet-channel' input is only supported when 'dotnet-version' is set to 'latest'.`
|
||||
@@ -192,7 +200,10 @@ export class DotnetVersionResolver {
|
||||
return this.resolvedArgument;
|
||||
}
|
||||
|
||||
private async getLatestVersion(channelFilter: string): Promise<string> {
|
||||
private async getLatestVersion(
|
||||
channelFilter: string,
|
||||
quality: QualityOptions = this.quality
|
||||
): Promise<string> {
|
||||
const httpClient = new hc.HttpClient('actions/setup-dotnet', [], {
|
||||
allowRetries: true,
|
||||
maxRetries: 3
|
||||
@@ -216,7 +227,7 @@ export class DotnetVersionResolver {
|
||||
|
||||
// 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'
|
||||
@@ -877,7 +888,8 @@ export class DotnetCoreInstaller {
|
||||
const versionResolver = new DotnetVersionResolver(
|
||||
this.version,
|
||||
this.quality,
|
||||
this.dotnetChannel
|
||||
this.dotnetChannel,
|
||||
this.rollForward
|
||||
);
|
||||
const dotnetVersion = await versionResolver.createDotnetVersion();
|
||||
|
||||
@@ -942,7 +954,20 @@ export class DotnetCoreInstaller {
|
||||
);
|
||||
}
|
||||
|
||||
return this.parseInstalledVersion(dotnetInstallOutput.stdout);
|
||||
const installedVersion = this.parseInstalledVersion(
|
||||
dotnetInstallOutput.stdout
|
||||
);
|
||||
if (
|
||||
installedVersion &&
|
||||
this.minimumVersion &&
|
||||
semver.valid(installedVersion) &&
|
||||
semver.lt(installedVersion, this.minimumVersion)
|
||||
) {
|
||||
throw new Error(
|
||||
`The installed .NET SDK ${installedVersion} is older than the global.json minimum version ${this.minimumVersion}.`
|
||||
);
|
||||
}
|
||||
return installedVersion;
|
||||
}
|
||||
|
||||
public async installRuntime(): Promise<string | null> {
|
||||
|
||||
Reference in New Issue
Block a user