GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Don't download releases-index.json to resolve major version (#560) · actions/setup-dotnet@f1970f5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • dist/setup
    • index.js
  • src
    • installer.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎dist/setup/index.js‎

Copy file name to clipboardExpand all lines: dist/setup/index.js
+16-18Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78768,7 +78768,22 @@ class DotnetVersionResolver {
7876878768
this.resolvedArgument.value = `${major}.${minor}`;
7876978769
}
7877078770
else if (this.isNumericTag(major)) {
78771-
this.resolvedArgument.value = await this.getLatestByMajorTag(major);
78771+
// Starting with .NET 5, the minor version is always zero.
78772+
// Hardcode the earlier versions because they will not get new releases.
78773+
switch (major) {
78774+
case '1':
78775+
this.resolvedArgument.value = '1.1';
78776+
break;
78777+
case '2':
78778+
this.resolvedArgument.value = '2.2';
78779+
break;
78780+
case '3':
78781+
this.resolvedArgument.value = '3.1';
78782+
break;
78783+
default:
78784+
this.resolvedArgument.value = `${major}.0`;
78785+
break;
78786+
}
7877278787
}
7877378788
else {
7877478789
// If "dotnet-version" is specified as *, x or X resolve latest version of .NET explicitly from LTS channel. The version argument will default to "latest" by install-dotnet script.
@@ -78832,23 +78847,6 @@ class DotnetVersionResolver {
7883278847
}
7883378848
return releasesInfo[0]['channel-version'];
7883478849
}
78835-
async getLatestByMajorTag(majorTag) {
78836-
const httpClient = new hc.HttpClient('actions/setup-dotnet', [], {
78837-
allowRetries: true,
78838-
maxRetries: 3
78839-
});
78840-
const response = await httpClient.getJson(DotnetVersionResolver.DotnetCoreIndexUrl);
78841-
const result = response.result || {};
78842-
const releasesInfo = result['releases-index'];
78843-
const releaseInfo = releasesInfo.find(info => {
78844-
const sdkParts = info['channel-version'].split('.');
78845-
return sdkParts[0] === majorTag;
78846-
});
78847-
if (!releaseInfo) {
78848-
throw new Error(`Could not find info for version with major tag: "${majorTag}" at ${DotnetVersionResolver.DotnetCoreIndexUrl}`);
78849-
}
78850-
return releaseInfo['channel-version'];
78851-
}
7885278850
static DotnetCoreIndexUrl = 'https://builds.dotnet.microsoft.com/dotnet/release-metadata/releases-index.json';
7885378851
}
7885478852
exports.DotnetVersionResolver = DotnetVersionResolver;
Collapse file

‎src/installer.ts‎

Copy file name to clipboardExpand all lines: src/installer.ts
+16-28Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,22 @@ export class DotnetVersionResolver {
125125
} else if (this.isNumericTag(major) && this.isNumericTag(minor)) {
126126
this.resolvedArgument.value = `${major}.${minor}`;
127127
} else if (this.isNumericTag(major)) {
128-
this.resolvedArgument.value = await this.getLatestByMajorTag(major);
128+
// Starting with .NET 5, the minor version is always zero.
129+
// Hardcode the earlier versions because they will not get new releases.
130+
switch (major) {
131+
case '1':
132+
this.resolvedArgument.value = '1.1';
133+
break;
134+
case '2':
135+
this.resolvedArgument.value = '2.2';
136+
break;
137+
case '3':
138+
this.resolvedArgument.value = '3.1';
139+
break;
140+
default:
141+
this.resolvedArgument.value = `${major}.0`;
142+
break;
143+
}
129144
} else {
130145
// If "dotnet-version" is specified as *, x or X resolve latest version of .NET explicitly from LTS channel. The version argument will default to "latest" by install-dotnet script.
131146
this.resolvedArgument.value = 'LTS';
@@ -207,33 +222,6 @@ export class DotnetVersionResolver {
207222
return releasesInfo[0]['channel-version'];
208223
}
209224

210-
private async getLatestByMajorTag(majorTag: string): Promise<string> {
211-
const httpClient = new hc.HttpClient('actions/setup-dotnet', [], {
212-
allowRetries: true,
213-
maxRetries: 3
214-
});
215-
216-
const response = await httpClient.getJson<any>(
217-
DotnetVersionResolver.DotnetCoreIndexUrl
218-
);
219-
220-
const result = response.result || {};
221-
const releasesInfo: any[] = result['releases-index'];
222-
223-
const releaseInfo = releasesInfo.find(info => {
224-
const sdkParts: string[] = info['channel-version'].split('.');
225-
return sdkParts[0] === majorTag;
226-
});
227-
228-
if (!releaseInfo) {
229-
throw new Error(
230-
`Could not find info for version with major tag: "${majorTag}" at ${DotnetVersionResolver.DotnetCoreIndexUrl}`
231-
);
232-
}
233-
234-
return releaseInfo['channel-version'];
235-
}
236-
237225
static DotnetCoreIndexUrl =
238226
'https://builds.dotnet.microsoft.com/dotnet/release-metadata/releases-index.json';
239227
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.