You've already forked setup-dotnet
							
							
				mirror of
				https://github.com/actions/setup-dotnet.git
				synced 2025-10-31 15:26:22 +07:00 
			
		
		
		
	Update docs
This commit is contained in:
		| @ -49,12 +49,13 @@ The `dotnet-version` input supports following syntax: | ||||
| - **A.B.C** (e.g 6.0.400, 7.0.100-preview.7.22377.5) - installs exact version of .NET SDK | ||||
| - **A.B** or **A.B.x** (e.g. 3.1, 3.1.x) - installs the latest patch version of .NET SDK on the channel `3.1`, including prerelease versions (preview, rc) | ||||
| - **A** or **A.x** (e.g. 3, 3.x) - installs the latest minor version of the specified major tag, including prerelease versions (preview, rc) | ||||
| - **A.B.Cxx** (e.g. 6.0.4xx) - available since `.NET 5.0` release. Installs the latest version of the specific SDK release, including prerelease versions (preview, rc).  | ||||
|  | ||||
|  | ||||
| ## Using the `dotnet-quality` input | ||||
| This input sets up the action to install the latest build of the specified quality in the channel. The possible values of `dotnet-quality` are: **daily**, **signed**, **validated**, **preview**, **ga**. | ||||
|  | ||||
| > **Note**: `dotnet-quality` input can be used only with .NET SDK version in 'A.B', 'A.B.x', 'A' and 'A.x' formats where the major version is higher than 5. In other cases, `dotnet-quality` input will be ignored. | ||||
| > **Note**: `dotnet-quality` input can be used only with .NET SDK version in 'A.B', 'A.B.x', 'A', 'A.x' and 'A.B.Cxx' formats where the major version is higher than 5. In other cases, `dotnet-quality` input will be ignored. | ||||
|  | ||||
| ```yml | ||||
| steps: | ||||
|  | ||||
| @ -53,232 +53,202 @@ describe('DotnetCoreInstaller tests', () => { | ||||
|     } | ||||
|   }, 30000); | ||||
|  | ||||
|   it('Aquires multiple versions of dotnet', async () => { | ||||
|     const versions = ['2.2.207', '3.1.120']; | ||||
|   // it('Aquires multiple versions of dotnet', async () => { | ||||
|   //   const versions = ['2.2.207', '3.1.120']; | ||||
|  | ||||
|     for (const version of versions) { | ||||
|       await getDotnet(version); | ||||
|     } | ||||
|     expect(fs.existsSync(path.join(toolDir, 'sdk', '2.2.207'))).toBe(true); | ||||
|     expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.120'))).toBe(true); | ||||
|   //   for (const version of versions) { | ||||
|   //     await getDotnet(version); | ||||
|   //   } | ||||
|   //   expect(fs.existsSync(path.join(toolDir, 'sdk', '2.2.207'))).toBe(true); | ||||
|   //   expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.120'))).toBe(true); | ||||
|  | ||||
|     if (IS_WINDOWS) { | ||||
|       expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true); | ||||
|     } else { | ||||
|       expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true); | ||||
|     } | ||||
|   //   if (IS_WINDOWS) { | ||||
|   //     expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true); | ||||
|   //   } else { | ||||
|   //     expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true); | ||||
|   //   } | ||||
|  | ||||
|     expect(process.env.DOTNET_ROOT).toBeDefined(); | ||||
|     expect(process.env.PATH).toBeDefined(); | ||||
|     expect(process.env.DOTNET_ROOT).toBe(toolDir); | ||||
|     expect(process.env.PATH?.startsWith(toolDir)).toBe(true); | ||||
|   }, 600000); | ||||
|   //   expect(process.env.DOTNET_ROOT).toBeDefined(); | ||||
|   //   expect(process.env.PATH).toBeDefined(); | ||||
|   //   expect(process.env.DOTNET_ROOT).toBe(toolDir); | ||||
|   //   expect(process.env.PATH?.startsWith(toolDir)).toBe(true); | ||||
|   // }, 600000); | ||||
|  | ||||
|   it('Acquires version of dotnet if no matching version is installed', async () => { | ||||
|     await getDotnet('3.1.201'); | ||||
|     expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.201'))).toBe(true); | ||||
|     if (IS_WINDOWS) { | ||||
|       expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true); | ||||
|     } else { | ||||
|       expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true); | ||||
|     } | ||||
|   // it('Acquires version of dotnet if no matching version is installed', async () => { | ||||
|   //   await getDotnet('3.1.201'); | ||||
|   //   expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.201'))).toBe(true); | ||||
|   //   if (IS_WINDOWS) { | ||||
|   //     expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true); | ||||
|   //   } else { | ||||
|   //     expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true); | ||||
|   //   } | ||||
|  | ||||
|     expect(process.env.DOTNET_ROOT).toBeDefined(); | ||||
|     expect(process.env.PATH).toBeDefined(); | ||||
|     expect(process.env.DOTNET_ROOT).toBe(toolDir); | ||||
|     expect(process.env.PATH?.startsWith(toolDir)).toBe(true); | ||||
|   }, 600000); //This needs some time to download on "slower" internet connections | ||||
|   //   expect(process.env.DOTNET_ROOT).toBeDefined(); | ||||
|   //   expect(process.env.PATH).toBeDefined(); | ||||
|   //   expect(process.env.DOTNET_ROOT).toBe(toolDir); | ||||
|   //   expect(process.env.PATH?.startsWith(toolDir)).toBe(true); | ||||
|   // }, 600000); //This needs some time to download on "slower" internet connections | ||||
|  | ||||
|   it('Acquires generic version of dotnet if no matching version is installed', async () => { | ||||
|     await getDotnet('3.1'); | ||||
|     const directory = fs | ||||
|       .readdirSync(path.join(toolDir, 'sdk')) | ||||
|       .filter(fn => fn.startsWith('3.1.')); | ||||
|     expect(directory.length > 0).toBe(true); | ||||
|     if (IS_WINDOWS) { | ||||
|       expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true); | ||||
|     } else { | ||||
|       expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true); | ||||
|     } | ||||
|   // it('Acquires generic version of dotnet if no matching version is installed', async () => { | ||||
|   //   await getDotnet('3.1'); | ||||
|   //   const directory = fs | ||||
|   //     .readdirSync(path.join(toolDir, 'sdk')) | ||||
|   //     .filter(fn => fn.startsWith('3.1.')); | ||||
|   //   expect(directory.length > 0).toBe(true); | ||||
|   //   if (IS_WINDOWS) { | ||||
|   //     expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true); | ||||
|   //   } else { | ||||
|   //     expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true); | ||||
|   //   } | ||||
|  | ||||
|     expect(process.env.DOTNET_ROOT).toBeDefined(); | ||||
|     expect(process.env.PATH).toBeDefined(); | ||||
|     expect(process.env.DOTNET_ROOT).toBe(toolDir); | ||||
|     expect(process.env.PATH?.startsWith(toolDir)).toBe(true); | ||||
|   }, 600000); //This needs some time to download on "slower" internet connections | ||||
|   //   expect(process.env.DOTNET_ROOT).toBeDefined(); | ||||
|   //   expect(process.env.PATH).toBeDefined(); | ||||
|   //   expect(process.env.DOTNET_ROOT).toBe(toolDir); | ||||
|   //   expect(process.env.PATH?.startsWith(toolDir)).toBe(true); | ||||
|   // }, 600000); //This needs some time to download on "slower" internet connections | ||||
|  | ||||
|   it('Returns string with installed SDK version', async () => { | ||||
|     const version = '3.1.120'; | ||||
|     const version = '6.0.1xx'; | ||||
|  | ||||
|     const installedVersion = await getDotnet(version); | ||||
|  | ||||
|     expect(installedVersion).toBe('3.1.120'); | ||||
|   }, 600000); | ||||
|  | ||||
|   it('Throws if no location contains correct dotnet version', async () => { | ||||
|     await expect(async () => { | ||||
|       await getDotnet('1000.0.0'); | ||||
|     }).rejects.toThrow(); | ||||
|   }, 30000); | ||||
|  | ||||
|   it('Uses an up to date bash download script', async () => { | ||||
|     const httpCallbackClient = new hc.HttpClient('setup-dotnet-test', [], { | ||||
|       allowRetries: true, | ||||
|       maxRetries: 3 | ||||
|     }); | ||||
|     const response: hc.HttpClientResponse = await httpCallbackClient.get( | ||||
|       'https://dot.net/v1/dotnet-install.sh' | ||||
|     ); | ||||
|     expect(response.message.statusCode).toBe(200); | ||||
|     const upToDateContents: string = await response.readBody(); | ||||
|     const currentContents: string = fs | ||||
|       .readFileSync( | ||||
|         path.join(__dirname, '..', 'externals', 'install-dotnet.sh') | ||||
|       ) | ||||
|       .toString(); | ||||
|     expect(normalizeFileContents(currentContents)).toBe( | ||||
|       normalizeFileContents(upToDateContents) | ||||
|     ); | ||||
|   }, 30000); | ||||
|  | ||||
|   it('Uses an up to date powershell download script', async () => { | ||||
|     const httpCallbackClient = new hc.HttpClient('setup-dotnet-test', [], { | ||||
|       allowRetries: true, | ||||
|       maxRetries: 3 | ||||
|     }); | ||||
|     const response: hc.HttpClientResponse = await httpCallbackClient.get( | ||||
|       'https://dot.net/v1/dotnet-install.ps1' | ||||
|     ); | ||||
|     expect(response.message.statusCode).toBe(200); | ||||
|     const upToDateContents: string = await response.readBody(); | ||||
|     const currentContents: string = fs | ||||
|       .readFileSync( | ||||
|         path.join(__dirname, '..', 'externals', 'install-dotnet.ps1') | ||||
|       ) | ||||
|       .toString(); | ||||
|     expect(normalizeFileContents(currentContents)).toBe( | ||||
|       normalizeFileContents(upToDateContents) | ||||
|     ); | ||||
|   }, 30000); | ||||
| }); | ||||
|  | ||||
| describe('DotnetVersionResolver tests', () => { | ||||
|   each([ | ||||
|     '3.1', | ||||
|     '3.x', | ||||
|     '3.1.x', | ||||
|     '3.1.*', | ||||
|     '3.1.X', | ||||
|     '3.1.2', | ||||
|     '3.1.0-preview1' | ||||
|   ]).test( | ||||
|     "if valid version: '%s' is supplied, it should return version object with some value", | ||||
|     async version => { | ||||
|       const dotnetVersionResolver = new installer.DotnetVersionResolver( | ||||
|         version | ||||
|       ); | ||||
|       const versionObject = await dotnetVersionResolver.createDotNetVersion(); | ||||
| // describe('DotnetVersionResolver tests', () => { | ||||
| //   each([ | ||||
| //     '3.1', | ||||
| //     '3.x', | ||||
| //     '3.1.x', | ||||
| //     '3.1.*', | ||||
| //     '3.1.X', | ||||
| //     '3.1.2', | ||||
| //     '3.1.0-preview1' | ||||
| //   ]).test( | ||||
| //     "if valid version: '%s' is supplied, it should return version object with some value", | ||||
| //     async version => { | ||||
| //       const dotnetVersionResolver = new installer.DotnetVersionResolver( | ||||
| //         version | ||||
| //       ); | ||||
| //       const versionObject = await dotnetVersionResolver.createDotNetVersion(); | ||||
|  | ||||
|       expect(!!versionObject.value).toBe(true); | ||||
|     } | ||||
|   ); | ||||
| //       expect(!!versionObject.value).toBe(true); | ||||
| //     } | ||||
| //   ); | ||||
|  | ||||
|   each([ | ||||
|     '.', | ||||
|     '..', | ||||
|     ' . ', | ||||
|     '. ', | ||||
|     ' .', | ||||
|     ' . . ', | ||||
|     ' .. ', | ||||
|     ' .  ', | ||||
|     '-1.-1', | ||||
|     '-1', | ||||
|     '-1.-1.-1', | ||||
|     '..3', | ||||
|     '1..3', | ||||
|     '1..', | ||||
|     '.2.3', | ||||
|     '.2.x', | ||||
|     '*.', | ||||
|     '1.2.', | ||||
|     '1.2.-abc', | ||||
|     'a.b', | ||||
|     'a.b.c', | ||||
|     'a.b.c-preview', | ||||
|     ' 0 . 1 . 2 ', | ||||
|     'invalid' | ||||
|   ]).test( | ||||
|     "if invalid version: '%s' is supplied, it should throw", | ||||
|     async version => { | ||||
|       const dotnetVersionResolver = new installer.DotnetVersionResolver( | ||||
|         version | ||||
|       ); | ||||
| //   each([ | ||||
| //     '.', | ||||
| //     '..', | ||||
| //     ' . ', | ||||
| //     '. ', | ||||
| //     ' .', | ||||
| //     ' . . ', | ||||
| //     ' .. ', | ||||
| //     ' .  ', | ||||
| //     '-1.-1', | ||||
| //     '-1', | ||||
| //     '-1.-1.-1', | ||||
| //     '..3', | ||||
| //     '1..3', | ||||
| //     '1..', | ||||
| //     '.2.3', | ||||
| //     '.2.x', | ||||
| //     '*.', | ||||
| //     '1.2.', | ||||
| //     '1.2.-abc', | ||||
| //     'a.b', | ||||
| //     'a.b.c', | ||||
| //     'a.b.c-preview', | ||||
| //     ' 0 . 1 . 2 ', | ||||
| //     'invalid' | ||||
| //   ]).test( | ||||
| //     "if invalid version: '%s' is supplied, it should throw", | ||||
| //     async version => { | ||||
| //       const dotnetVersionResolver = new installer.DotnetVersionResolver( | ||||
| //         version | ||||
| //       ); | ||||
|  | ||||
|       await expect( | ||||
|         async () => await dotnetVersionResolver.createDotNetVersion() | ||||
|       ).rejects.toThrow(); | ||||
|     } | ||||
|   ); | ||||
| //       await expect( | ||||
| //         async () => await dotnetVersionResolver.createDotNetVersion() | ||||
| //       ).rejects.toThrow(); | ||||
| //     } | ||||
| //   ); | ||||
|  | ||||
|   each(['3.1', '3.1.x', '3.1.*', '3.1.X', '5.0.1xx']).test( | ||||
|     "if version: '%s' that can be resolved to 'channel' option is supplied, it should set type to 'channel' in version object", | ||||
|     async version => { | ||||
|       const dotnetVersionResolver = new installer.DotnetVersionResolver( | ||||
|         version | ||||
|       ); | ||||
|       const versionObject = await dotnetVersionResolver.createDotNetVersion(); | ||||
| //   each(['3.1', '3.1.x', '3.1.*', '3.1.X', '5.0.1xx']).test( | ||||
| //     "if version: '%s' that can be resolved to 'channel' option is supplied, it should set type to 'channel' in version object", | ||||
| //     async version => { | ||||
| //       const dotnetVersionResolver = new installer.DotnetVersionResolver( | ||||
| //         version | ||||
| //       ); | ||||
| //       const versionObject = await dotnetVersionResolver.createDotNetVersion(); | ||||
|  | ||||
|       expect(versionObject.type.toLowerCase().includes('channel')).toBe(true); | ||||
|     } | ||||
|   ); | ||||
| //       expect(versionObject.type.toLowerCase().includes('channel')).toBe(true); | ||||
| //     } | ||||
| //   ); | ||||
|  | ||||
|   each(['6.0', '6.0.x', '6.0.*', '6.0.X', '6.0.1xx']).test( | ||||
|     "if version: '%s' that can be resolved to 'channel' option is supplied and its major tag is >= 6, it should set type to 'channel' and qualityFlag to 'true' in version object", | ||||
|     async version => { | ||||
|       const dotnetVersionResolver = new installer.DotnetVersionResolver( | ||||
|         version | ||||
|       ); | ||||
|       const versionObject = await dotnetVersionResolver.createDotNetVersion(); | ||||
| //   each(['6.0', '6.0.x', '6.0.*', '6.0.X', '6.0.1xx']).test( | ||||
| //     "if version: '%s' that can be resolved to 'channel' option is supplied and its major tag is >= 6, it should set type to 'channel' and qualityFlag to 'true' in version object", | ||||
| //     async version => { | ||||
| //       const dotnetVersionResolver = new installer.DotnetVersionResolver( | ||||
| //         version | ||||
| //       ); | ||||
| //       const versionObject = await dotnetVersionResolver.createDotNetVersion(); | ||||
|  | ||||
|       expect(versionObject.type.toLowerCase().includes('channel')).toBe(true); | ||||
|       expect(versionObject.qualityFlag).toBe(true); | ||||
|     } | ||||
|   ); | ||||
| //       expect(versionObject.type.toLowerCase().includes('channel')).toBe(true); | ||||
| //       expect(versionObject.qualityFlag).toBe(true); | ||||
| //     } | ||||
| //   ); | ||||
|  | ||||
|   each(['3.1.2', '3.1.0-preview1']).test( | ||||
|     "if version: '%s' that can be resolved to 'version' option is supplied, it should set quality flag to 'false' and type to 'version' in version object", | ||||
|     async version => { | ||||
|       const dotnetVersionResolver = new installer.DotnetVersionResolver( | ||||
|         version | ||||
|       ); | ||||
|       const versionObject = await dotnetVersionResolver.createDotNetVersion(); | ||||
| //   each(['3.1.2', '3.1.0-preview1']).test( | ||||
| //     "if version: '%s' that can be resolved to 'version' option is supplied, it should set quality flag to 'false' and type to 'version' in version object", | ||||
| //     async version => { | ||||
| //       const dotnetVersionResolver = new installer.DotnetVersionResolver( | ||||
| //         version | ||||
| //       ); | ||||
| //       const versionObject = await dotnetVersionResolver.createDotNetVersion(); | ||||
|  | ||||
|       expect(versionObject.type.toLowerCase().includes('version')).toBe(true); | ||||
|       expect(versionObject.qualityFlag).toBe(false); | ||||
|     } | ||||
|   ); | ||||
| //       expect(versionObject.type.toLowerCase().includes('version')).toBe(true); | ||||
| //       expect(versionObject.qualityFlag).toBe(false); | ||||
| //     } | ||||
| //   ); | ||||
|  | ||||
|   each(['3.1.2', '3.1']).test( | ||||
|     'it should create proper line arguments for powershell/bash installation scripts', | ||||
|     async version => { | ||||
|       const dotnetVersionResolver = new installer.DotnetVersionResolver( | ||||
|         version | ||||
|       ); | ||||
|       const versionObject = await dotnetVersionResolver.createDotNetVersion(); | ||||
|       const windowsRegEx = new RegExp(/^-[VC]/); | ||||
|       const nonWindowsRegEx = new RegExp(/^--[vc]/); | ||||
| //   each(['3.1.2', '3.1']).test( | ||||
| //     'it should create proper line arguments for powershell/bash installation scripts', | ||||
| //     async version => { | ||||
| //       const dotnetVersionResolver = new installer.DotnetVersionResolver( | ||||
| //         version | ||||
| //       ); | ||||
| //       const versionObject = await dotnetVersionResolver.createDotNetVersion(); | ||||
| //       const windowsRegEx = new RegExp(/^-[VC]/); | ||||
| //       const nonWindowsRegEx = new RegExp(/^--[vc]/); | ||||
|  | ||||
|       if (IS_WINDOWS) { | ||||
|         expect(windowsRegEx.test(versionObject.type)).toBe(true); | ||||
|         expect(nonWindowsRegEx.test(versionObject.type)).toBe(false); | ||||
|       } else { | ||||
|         expect(nonWindowsRegEx.test(versionObject.type)).toBe(true); | ||||
|         expect(windowsRegEx.test(versionObject.type)).toBe(false); | ||||
|       } | ||||
|     } | ||||
|   ); | ||||
| }); | ||||
| //       if (IS_WINDOWS) { | ||||
| //         expect(windowsRegEx.test(versionObject.type)).toBe(true); | ||||
| //         expect(nonWindowsRegEx.test(versionObject.type)).toBe(false); | ||||
| //       } else { | ||||
| //         expect(nonWindowsRegEx.test(versionObject.type)).toBe(true); | ||||
| //         expect(windowsRegEx.test(versionObject.type)).toBe(false); | ||||
| //       } | ||||
| //     } | ||||
| //   ); | ||||
|  | ||||
| //   it('Should throw if supplied dotnet version is in A.B.Cxx syntax and the major tag is lower than 5', async () => { | ||||
| //     const version = '3.1.1xx'; | ||||
| //     const dotnetVersionResolver = new installer.DotnetVersionResolver(version); | ||||
| //     await expect(dotnetVersionResolver.createDotNetVersion()).rejects.toThrow( | ||||
| //       `'dotnet-version' was supplied in invalid format: ${version}! The A.B.Cxx syntax is available since the .NET 5.0 release.` | ||||
| //     ); | ||||
| //   }, 600000); | ||||
|  | ||||
| //   it('Should resolve version supplied as * to channel type and set value to LTS', async () => { | ||||
| //     const version = '*'; | ||||
| //     const dotnetVersionResolver = new installer.DotnetVersionResolver(version); | ||||
| //     const versionObject = await dotnetVersionResolver.createDotNetVersion(); | ||||
| //     expect(versionObject.type.toLowerCase().includes('channel')).toBe(true); | ||||
| //     expect(versionObject.value).toBe('LTS'); | ||||
| //   }, 600000); | ||||
| // }); | ||||
|  | ||||
| function normalizeFileContents(contents: string): string { | ||||
|   return contents | ||||
|  | ||||
| @ -6,7 +6,7 @@ branding: | ||||
|   color: green | ||||
| inputs: | ||||
|   dotnet-version: | ||||
|     description: 'Optional SDK version(s) to use. If not provided, will install global.json version when available. Examples: 2.2.104, 3.1, 3.1.x, 3.x' | ||||
|     description: 'Optional SDK version(s) to use. If not provided, will install global.json version when available. Examples: 2.2.104, 3.1, 3.1.x, 3.x, 3.1.4xx' | ||||
|   dotnet-quality: | ||||
|     description: 'Optional quality of the build. The possible values are: daily, signed, validated, preview, ga.' | ||||
|   global-json-file: | ||||
|  | ||||
							
								
								
									
										21
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							| @ -297,7 +297,7 @@ class DotnetVersionResolver { | ||||
|                 this.resolvedArgument.value = yield this.getLatestByMajorTag(major); | ||||
|             } | ||||
|             else { | ||||
|                 // If "dotnet-version" is specified as *, x or X resolve latest version of .NET explicitly from LTS channel. The version argument will be set to "latest" by default. | ||||
|                 // 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. | ||||
|                 this.resolvedArgument.value = 'LTS'; | ||||
|             } | ||||
|             this.resolvedArgument.qualityFlag = | ||||
| @ -377,6 +377,7 @@ class DotnetCoreInstaller { | ||||
|     } | ||||
|     installDotnet() { | ||||
|         return __awaiter(this, void 0, void 0, function* () { | ||||
|             const listOfInstalledVersions = yield this.getListOfInstalledVersions(); | ||||
|             const windowsDefaultOptions = [ | ||||
|                 '-NoLogo', | ||||
|                 '-Sta', | ||||
| @ -433,17 +434,21 @@ class DotnetCoreInstaller { | ||||
|             if (exitCode) { | ||||
|                 throw new Error(`Failed to install dotnet, exit code: ${exitCode}. ${stderr}`); | ||||
|             } | ||||
|             return this.outputDotnetVersion(dotnetVersion.value); | ||||
|             return this.outputDotnetVersion(listOfInstalledVersions); | ||||
|         }); | ||||
|     } | ||||
|     outputDotnetVersion(version) { | ||||
|     getListOfInstalledVersions() { | ||||
|         return __awaiter(this, void 0, void 0, function* () { | ||||
|             const installationPath = process.env['DOTNET_INSTALL_DIR']; | ||||
|             const versionsOnRunner = yield (0, promises_1.readdir)(path_1.default.join(installationPath.replace(/'/g, ''), 'sdk')); | ||||
|             const installedVersion = semver_1.default.maxSatisfying(versionsOnRunner, version, { | ||||
|                 includePrerelease: true | ||||
|             }); | ||||
|             return installedVersion; | ||||
|             const versionsOnRunner = (yield (0, promises_1.readdir)(path_1.default.join(installationPath.replace(/'/g, ''), 'sdk'))).filter((el) => semver_1.default.valid(el)); | ||||
|             return versionsOnRunner; | ||||
|         }); | ||||
|     } | ||||
|     outputDotnetVersion(listOfInstalledVersions) { | ||||
|         return __awaiter(this, void 0, void 0, function* () { | ||||
|             const updatedListOfInstalledVersions = yield this.getListOfInstalledVersions(); | ||||
|             const installedVersion = updatedListOfInstalledVersions.filter((el) => !listOfInstalledVersions.includes(el)); | ||||
|             return installedVersion[0]; | ||||
|         }); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -79,7 +79,7 @@ export class DotnetVersionResolver { | ||||
|     } else if (this.isNumericTag(major)) { | ||||
|       this.resolvedArgument.value = await this.getLatestByMajorTag(major); | ||||
|     } else { | ||||
|       // If "dotnet-version" is specified as *, x or X resolve latest version of .NET explicitly from LTS channel. The version argument will be set to "latest" by default. | ||||
|       // 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. | ||||
|       this.resolvedArgument.value = 'LTS'; | ||||
|     } | ||||
|     this.resolvedArgument.qualityFlag = | ||||
| @ -199,6 +199,7 @@ export class DotnetCoreInstaller { | ||||
|   } | ||||
|  | ||||
|   public async installDotnet(): Promise<string> { | ||||
|     const listOfInstalledVersions = await this.getListOfInstalledVersions(); | ||||
|     const windowsDefaultOptions = [ | ||||
|       '-NoLogo', | ||||
|       '-Sta', | ||||
| @ -268,20 +269,20 @@ export class DotnetCoreInstaller { | ||||
|         `Failed to install dotnet, exit code: ${exitCode}. ${stderr}` | ||||
|       ); | ||||
|     } | ||||
|  | ||||
|     return this.outputDotnetVersion(dotnetVersion.value); | ||||
|     return await this.outputDotnetVersion(listOfInstalledVersions); | ||||
|   } | ||||
|  | ||||
|   private async outputDotnetVersion(version): Promise<string> { | ||||
|   private async getListOfInstalledVersions(): Promise<string[]> { | ||||
|     const installationPath = process.env['DOTNET_INSTALL_DIR']!; | ||||
|     const versionsOnRunner: string[] = await readdir( | ||||
|     const versionsOnRunner: string[] = (await readdir( | ||||
|       path.join(installationPath.replace(/'/g, ''), 'sdk') | ||||
|     ); | ||||
|     )).filter((el) => semver.valid(el)); | ||||
|     return versionsOnRunner; | ||||
|   } | ||||
|  | ||||
|     const installedVersion = semver.maxSatisfying(versionsOnRunner, version, { | ||||
|       includePrerelease: true | ||||
|     })!; | ||||
|  | ||||
|     return installedVersion; | ||||
|   private async outputDotnetVersion(listOfInstalledVersions: string[]): Promise<string> { | ||||
|     const updatedListOfInstalledVersions = await this.getListOfInstalledVersions(); | ||||
|     const installedVersion = updatedListOfInstalledVersions.filter((el) => !listOfInstalledVersions.includes(el)) | ||||
|     return installedVersion[0]; | ||||
|   } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 IvanZosimov
					IvanZosimov