@@ -125,7 +125,22 @@ export class DotnetVersionResolver { |
125 | 125 | } else if (this.isNumericTag(major) && this.isNumericTag(minor)) { |
126 | 126 | this.resolvedArgument.value = `${major}.${minor}`; |
127 | 127 | } 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 | + } |
129 | 144 | } else { |
130 | 145 | // 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. |
131 | 146 | this.resolvedArgument.value = 'LTS'; |
@@ -207,33 +222,6 @@ export class DotnetVersionResolver { |
207 | 222 | return releasesInfo[0]['channel-version']; |
208 | 223 | } |
209 | 224 |
|
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 | | - |
237 | 225 | static DotnetCoreIndexUrl = |
238 | 226 | 'https://builds.dotnet.microsoft.com/dotnet/release-metadata/releases-index.json'; |
239 | 227 | } |
|