mirror of
				https://github.com/actions/setup-dotnet.git
				synced 2025-10-31 15:53:45 +00:00 
			
		
		
		
	Merge pull request #432 from akv-platform/refactor-installer
Refactor installer
This commit is contained in:
		
						commit
						7ed547ca75
					
				| @ -297,14 +297,14 @@ describe('installer tests', () => { | |||||||
|     describe('addToPath() tests', () => { |     describe('addToPath() tests', () => { | ||||||
|       it(`should export DOTNET_ROOT env.var with value from DOTNET_INSTALL_DIR env.var`, async () => { |       it(`should export DOTNET_ROOT env.var with value from DOTNET_INSTALL_DIR env.var`, async () => { | ||||||
|         process.env['DOTNET_INSTALL_DIR'] = 'fictitious/dotnet/install/dir'; |         process.env['DOTNET_INSTALL_DIR'] = 'fictitious/dotnet/install/dir'; | ||||||
|         installer.DotnetCoreInstaller.addToPath(); |         installer.DotnetInstallDir.addToPath(); | ||||||
|         const dotnet_root = process.env['DOTNET_ROOT']; |         const dotnet_root = process.env['DOTNET_ROOT']; | ||||||
|         expect(dotnet_root).toBe(process.env['DOTNET_INSTALL_DIR']); |         expect(dotnet_root).toBe(process.env['DOTNET_INSTALL_DIR']); | ||||||
|       }); |       }); | ||||||
| 
 | 
 | ||||||
|       it(`should export value from DOTNET_INSTALL_DIR env.var to the PATH`, async () => { |       it(`should export value from DOTNET_INSTALL_DIR env.var to the PATH`, async () => { | ||||||
|         process.env['DOTNET_INSTALL_DIR'] = 'fictitious/dotnet/install/dir'; |         process.env['DOTNET_INSTALL_DIR'] = 'fictitious/dotnet/install/dir'; | ||||||
|         installer.DotnetCoreInstaller.addToPath(); |         installer.DotnetInstallDir.addToPath(); | ||||||
|         const path = process.env['PATH']; |         const path = process.env['PATH']; | ||||||
|         expect(path).toContain(process.env['DOTNET_INSTALL_DIR']); |         expect(path).toContain(process.env['DOTNET_INSTALL_DIR']); | ||||||
|       }); |       }); | ||||||
| @ -312,7 +312,7 @@ describe('installer tests', () => { | |||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   describe('DotnetVersionResolver tests', () => { |   describe('DotnetVersionResolver tests', () => { | ||||||
|     describe('createDotNetVersion() tests', () => { |     describe('createDotnetVersion() tests', () => { | ||||||
|       each([ |       each([ | ||||||
|         '3.1', |         '3.1', | ||||||
|         '3.x', |         '3.x', | ||||||
| @ -329,7 +329,7 @@ describe('installer tests', () => { | |||||||
|             version |             version | ||||||
|           ); |           ); | ||||||
|           const versionObject = |           const versionObject = | ||||||
|             await dotnetVersionResolver.createDotNetVersion(); |             await dotnetVersionResolver.createDotnetVersion(); | ||||||
| 
 | 
 | ||||||
|           expect(!!versionObject.value).toBe(true); |           expect(!!versionObject.value).toBe(true); | ||||||
|         } |         } | ||||||
| @ -368,7 +368,7 @@ describe('installer tests', () => { | |||||||
|           ); |           ); | ||||||
| 
 | 
 | ||||||
|           await expect( |           await expect( | ||||||
|             async () => await dotnetVersionResolver.createDotNetVersion() |             async () => await dotnetVersionResolver.createDotnetVersion() | ||||||
|           ).rejects.toThrow(); |           ).rejects.toThrow(); | ||||||
|         } |         } | ||||||
|       ); |       ); | ||||||
| @ -380,7 +380,7 @@ describe('installer tests', () => { | |||||||
|             version |             version | ||||||
|           ); |           ); | ||||||
|           const versionObject = |           const versionObject = | ||||||
|             await dotnetVersionResolver.createDotNetVersion(); |             await dotnetVersionResolver.createDotnetVersion(); | ||||||
| 
 | 
 | ||||||
|           expect(versionObject.type.toLowerCase().includes('channel')).toBe( |           expect(versionObject.type.toLowerCase().includes('channel')).toBe( | ||||||
|             true |             true | ||||||
| @ -395,7 +395,7 @@ describe('installer tests', () => { | |||||||
|             version |             version | ||||||
|           ); |           ); | ||||||
|           const versionObject = |           const versionObject = | ||||||
|             await dotnetVersionResolver.createDotNetVersion(); |             await dotnetVersionResolver.createDotnetVersion(); | ||||||
| 
 | 
 | ||||||
|           expect(versionObject.type.toLowerCase().includes('channel')).toBe( |           expect(versionObject.type.toLowerCase().includes('channel')).toBe( | ||||||
|             true |             true | ||||||
| @ -411,7 +411,7 @@ describe('installer tests', () => { | |||||||
|             version |             version | ||||||
|           ); |           ); | ||||||
|           const versionObject = |           const versionObject = | ||||||
|             await dotnetVersionResolver.createDotNetVersion(); |             await dotnetVersionResolver.createDotnetVersion(); | ||||||
| 
 | 
 | ||||||
|           expect(versionObject.type.toLowerCase().includes('version')).toBe( |           expect(versionObject.type.toLowerCase().includes('version')).toBe( | ||||||
|             true |             true | ||||||
| @ -427,7 +427,7 @@ describe('installer tests', () => { | |||||||
|             version |             version | ||||||
|           ); |           ); | ||||||
|           const versionObject = |           const versionObject = | ||||||
|             await dotnetVersionResolver.createDotNetVersion(); |             await dotnetVersionResolver.createDotnetVersion(); | ||||||
|           const windowsRegEx = new RegExp(/^-(Version|Channel)/); |           const windowsRegEx = new RegExp(/^-(Version|Channel)/); | ||||||
|           const nonWindowsRegEx = new RegExp(/^--(version|channel)/); |           const nonWindowsRegEx = new RegExp(/^--(version|channel)/); | ||||||
| 
 | 
 | ||||||
| @ -447,7 +447,7 @@ describe('installer tests', () => { | |||||||
|           version |           version | ||||||
|         ); |         ); | ||||||
|         await expect( |         await expect( | ||||||
|           async () => await dotnetVersionResolver.createDotNetVersion() |           async () => await dotnetVersionResolver.createDotnetVersion() | ||||||
|         ).rejects.toThrow( |         ).rejects.toThrow( | ||||||
|           `'dotnet-version' was supplied in invalid format: ${version}! The A.B.Cxx syntax is available since the .NET 5.0 release.` |           `'dotnet-version' was supplied in invalid format: ${version}! The A.B.Cxx syntax is available since the .NET 5.0 release.` | ||||||
|         ); |         ); | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ import semver from 'semver'; | |||||||
| import * as auth from '../src/authutil'; | import * as auth from '../src/authutil'; | ||||||
| 
 | 
 | ||||||
| import * as setup from '../src/setup-dotnet'; | import * as setup from '../src/setup-dotnet'; | ||||||
| import {DotnetCoreInstaller} from '../src/installer'; | import {DotnetCoreInstaller, DotnetInstallDir} from '../src/installer'; | ||||||
| import * as cacheUtils from '../src/cache-utils'; | import * as cacheUtils from '../src/cache-utils'; | ||||||
| import * as cacheRestore from '../src/cache-restore'; | import * as cacheRestore from '../src/cache-restore'; | ||||||
| 
 | 
 | ||||||
| @ -28,22 +28,25 @@ describe('setup-dotnet tests', () => { | |||||||
|     DotnetCoreInstaller.prototype, |     DotnetCoreInstaller.prototype, | ||||||
|     'installDotnet' |     'installDotnet' | ||||||
|   ); |   ); | ||||||
|   const addToPathSpy = jest.spyOn(DotnetCoreInstaller, 'addToPath'); | 
 | ||||||
|   const isCacheFeatureAvailableSpy = jest.spyOn( |   const isCacheFeatureAvailableSpy = jest.spyOn( | ||||||
|     cacheUtils, |     cacheUtils, | ||||||
|     'isCacheFeatureAvailable' |     'isCacheFeatureAvailable' | ||||||
|   ); |   ); | ||||||
|   const restoreCacheSpy = jest.spyOn(cacheRestore, 'restoreCache'); |   const restoreCacheSpy = jest.spyOn(cacheRestore, 'restoreCache'); | ||||||
|   const configAuthenticationSpy = jest.spyOn(auth, 'configAuthentication'); |   const configAuthenticationSpy = jest.spyOn(auth, 'configAuthentication'); | ||||||
|  |   const addToPathOriginal = DotnetInstallDir.addToPath; | ||||||
| 
 | 
 | ||||||
|   describe('run() tests', () => { |   describe('run() tests', () => { | ||||||
|     beforeEach(() => { |     beforeEach(() => { | ||||||
|  |       DotnetInstallDir.addToPath = jest.fn(); | ||||||
|       getMultilineInputSpy.mockImplementation(input => inputs[input as string]); |       getMultilineInputSpy.mockImplementation(input => inputs[input as string]); | ||||||
|       getInputSpy.mockImplementation(input => inputs[input as string]); |       getInputSpy.mockImplementation(input => inputs[input as string]); | ||||||
|       getBooleanInputSpy.mockImplementation(input => inputs[input as string]); |       getBooleanInputSpy.mockImplementation(input => inputs[input as string]); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     afterEach(() => { |     afterEach(() => { | ||||||
|  |       DotnetInstallDir.addToPath = addToPathOriginal; | ||||||
|       jest.clearAllMocks(); |       jest.clearAllMocks(); | ||||||
|       jest.resetAllMocks(); |       jest.resetAllMocks(); | ||||||
|     }); |     }); | ||||||
| @ -104,10 +107,9 @@ describe('setup-dotnet tests', () => { | |||||||
|       inputs['dotnet-quality'] = ''; |       inputs['dotnet-quality'] = ''; | ||||||
| 
 | 
 | ||||||
|       installDotnetSpy.mockImplementation(() => Promise.resolve('')); |       installDotnetSpy.mockImplementation(() => Promise.resolve('')); | ||||||
|       addToPathSpy.mockImplementation(() => {}); |  | ||||||
| 
 | 
 | ||||||
|       await setup.run(); |       await setup.run(); | ||||||
|       expect(addToPathSpy).toHaveBeenCalledTimes(1); |       expect(DotnetInstallDir.addToPath).toHaveBeenCalledTimes(1); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     it('should call auth.configAuthentication() if source-url input is provided', async () => { |     it('should call auth.configAuthentication() if source-url input is provided', async () => { | ||||||
| @ -148,10 +150,9 @@ describe('setup-dotnet tests', () => { | |||||||
|       installDotnetSpy.mockImplementation(() => |       installDotnetSpy.mockImplementation(() => | ||||||
|         Promise.resolve(`${inputs['dotnet-version']}`) |         Promise.resolve(`${inputs['dotnet-version']}`) | ||||||
|       ); |       ); | ||||||
|       addToPathSpy.mockImplementation(() => {}); |  | ||||||
| 
 | 
 | ||||||
|       await setup.run(); |       await setup.run(); | ||||||
|       expect(setOutputSpy).toHaveBeenCalledTimes(1); |       expect(DotnetInstallDir.addToPath).toHaveBeenCalledTimes(1); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     it(`shouldn't call setOutput() if parsing dotnet-installer logs failed`, async () => { |     it(`shouldn't call setOutput() if parsing dotnet-installer logs failed`, async () => { | ||||||
| @ -159,7 +160,6 @@ describe('setup-dotnet tests', () => { | |||||||
|       const warningMessage = `Failed to output the installed version of .NET. The 'dotnet-version' output will not be set.`; |       const warningMessage = `Failed to output the installed version of .NET. The 'dotnet-version' output will not be set.`; | ||||||
| 
 | 
 | ||||||
|       installDotnetSpy.mockImplementation(() => Promise.resolve(null)); |       installDotnetSpy.mockImplementation(() => Promise.resolve(null)); | ||||||
|       addToPathSpy.mockImplementation(() => {}); |  | ||||||
| 
 | 
 | ||||||
|       await setup.run(); |       await setup.run(); | ||||||
|       expect(warningSpy).toHaveBeenCalledWith(warningMessage); |       expect(warningSpy).toHaveBeenCalledWith(warningMessage); | ||||||
| @ -170,8 +170,6 @@ describe('setup-dotnet tests', () => { | |||||||
|       inputs['dotnet-version'] = []; |       inputs['dotnet-version'] = []; | ||||||
|       const warningMessage = `The 'dotnet-version' output will not be set.`; |       const warningMessage = `The 'dotnet-version' output will not be set.`; | ||||||
| 
 | 
 | ||||||
|       addToPathSpy.mockImplementation(() => {}); |  | ||||||
| 
 |  | ||||||
|       await setup.run(); |       await setup.run(); | ||||||
| 
 | 
 | ||||||
|       expect(infoSpy).toHaveBeenCalledWith(warningMessage); |       expect(infoSpy).toHaveBeenCalledWith(warningMessage); | ||||||
| @ -185,7 +183,6 @@ describe('setup-dotnet tests', () => { | |||||||
|       inputs['cache-dependency-path'] = 'fictitious.package.lock.json'; |       inputs['cache-dependency-path'] = 'fictitious.package.lock.json'; | ||||||
| 
 | 
 | ||||||
|       installDotnetSpy.mockImplementation(() => Promise.resolve('')); |       installDotnetSpy.mockImplementation(() => Promise.resolve('')); | ||||||
|       addToPathSpy.mockImplementation(() => {}); |  | ||||||
| 
 | 
 | ||||||
|       isCacheFeatureAvailableSpy.mockImplementation(() => true); |       isCacheFeatureAvailableSpy.mockImplementation(() => true); | ||||||
|       restoreCacheSpy.mockImplementation(() => Promise.resolve()); |       restoreCacheSpy.mockImplementation(() => Promise.resolve()); | ||||||
| @ -203,7 +200,6 @@ describe('setup-dotnet tests', () => { | |||||||
|       inputs['cache'] = false; |       inputs['cache'] = false; | ||||||
| 
 | 
 | ||||||
|       installDotnetSpy.mockImplementation(() => Promise.resolve('')); |       installDotnetSpy.mockImplementation(() => Promise.resolve('')); | ||||||
|       addToPathSpy.mockImplementation(() => {}); |  | ||||||
| 
 | 
 | ||||||
|       isCacheFeatureAvailableSpy.mockImplementation(() => true); |       isCacheFeatureAvailableSpy.mockImplementation(() => true); | ||||||
|       restoreCacheSpy.mockImplementation(() => Promise.resolve()); |       restoreCacheSpy.mockImplementation(() => Promise.resolve()); | ||||||
| @ -218,7 +214,6 @@ describe('setup-dotnet tests', () => { | |||||||
|       inputs['cache'] = true; |       inputs['cache'] = true; | ||||||
| 
 | 
 | ||||||
|       installDotnetSpy.mockImplementation(() => Promise.resolve('')); |       installDotnetSpy.mockImplementation(() => Promise.resolve('')); | ||||||
|       addToPathSpy.mockImplementation(() => {}); |  | ||||||
| 
 | 
 | ||||||
|       isCacheFeatureAvailableSpy.mockImplementation(() => false); |       isCacheFeatureAvailableSpy.mockImplementation(() => false); | ||||||
|       restoreCacheSpy.mockImplementation(() => Promise.resolve()); |       restoreCacheSpy.mockImplementation(() => Promise.resolve()); | ||||||
|  | |||||||
							
								
								
									
										426
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										426
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							| @ -58476,91 +58476,91 @@ exports["default"] = _default; | |||||||
| /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { | /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { | ||||||
| 
 | 
 | ||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||||||
|     if (k2 === undefined) k2 = k; |     if (k2 === undefined) k2 = k; | ||||||
|     var desc = Object.getOwnPropertyDescriptor(m, k); |     var desc = Object.getOwnPropertyDescriptor(m, k); | ||||||
|     if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { |     if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||||||
|       desc = { enumerable: true, get: function() { return m[k]; } }; |       desc = { enumerable: true, get: function() { return m[k]; } }; | ||||||
|     } |     } | ||||||
|     Object.defineProperty(o, k2, desc); |     Object.defineProperty(o, k2, desc); | ||||||
| }) : (function(o, m, k, k2) { | }) : (function(o, m, k, k2) { | ||||||
|     if (k2 === undefined) k2 = k; |     if (k2 === undefined) k2 = k; | ||||||
|     o[k2] = m[k]; |     o[k2] = m[k]; | ||||||
| })); | })); | ||||||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||||||
|     Object.defineProperty(o, "default", { enumerable: true, value: v }); |     Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||||||
| }) : function(o, v) { | }) : function(o, v) { | ||||||
|     o["default"] = v; |     o["default"] = v; | ||||||
| }); | }); | ||||||
| var __importStar = (this && this.__importStar) || function (mod) { | var __importStar = (this && this.__importStar) || function (mod) { | ||||||
|     if (mod && mod.__esModule) return mod; |     if (mod && mod.__esModule) return mod; | ||||||
|     var result = {}; |     var result = {}; | ||||||
|     if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); |     if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||||||
|     __setModuleDefault(result, mod); |     __setModuleDefault(result, mod); | ||||||
|     return result; |     return result; | ||||||
| }; | }; | ||||||
| var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||||||
|     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||||||
|     return new (P || (P = Promise))(function (resolve, reject) { |     return new (P || (P = Promise))(function (resolve, reject) { | ||||||
|         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } |         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||||||
|         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } |         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||||||
|         function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } |         function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||||||
|         step((generator = generator.apply(thisArg, _arguments || [])).next()); |         step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||||||
|     }); |     }); | ||||||
| }; | }; | ||||||
| var __importDefault = (this && this.__importDefault) || function (mod) { | var __importDefault = (this && this.__importDefault) || function (mod) { | ||||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; |     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||||
| }; | }; | ||||||
| Object.defineProperty(exports, "__esModule", ({ value: true })); | Object.defineProperty(exports, "__esModule", ({ value: true })); | ||||||
| exports.run = void 0; | exports.run = void 0; | ||||||
| const core = __importStar(__nccwpck_require__(2186)); | const core = __importStar(__nccwpck_require__(2186)); | ||||||
| const cache = __importStar(__nccwpck_require__(7799)); | const cache = __importStar(__nccwpck_require__(7799)); | ||||||
| const node_fs_1 = __importDefault(__nccwpck_require__(7561)); | const node_fs_1 = __importDefault(__nccwpck_require__(7561)); | ||||||
| const cache_utils_1 = __nccwpck_require__(1678); | const cache_utils_1 = __nccwpck_require__(1678); | ||||||
| const constants_1 = __nccwpck_require__(9042); | const constants_1 = __nccwpck_require__(9042); | ||||||
| // Catch and log any unhandled exceptions.  These exceptions can leak out of the uploadChunk method in
 | // Catch and log any unhandled exceptions.  These exceptions can leak out of the uploadChunk method in
 | ||||||
| // @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
 | // @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
 | ||||||
| // throw an uncaught exception.  Instead of failing this action, just warn.
 | // throw an uncaught exception.  Instead of failing this action, just warn.
 | ||||||
| process.on('uncaughtException', e => { | process.on('uncaughtException', e => { | ||||||
|     const warningPrefix = '[warning]'; |     const warningPrefix = '[warning]'; | ||||||
|     core.info(`${warningPrefix}${e.message}`); |     core.info(`${warningPrefix}${e.message}`); | ||||||
| }); | }); | ||||||
| function run() { | function run() { | ||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         try { |         try { | ||||||
|             if (core.getBooleanInput('cache')) { |             if (core.getBooleanInput('cache')) { | ||||||
|                 yield cachePackages(); |                 yield cachePackages(); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         catch (error) { |         catch (error) { | ||||||
|             core.setFailed(error.message); |             core.setFailed(error.message); | ||||||
|         } |         } | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
| exports.run = run; | exports.run = run; | ||||||
| const cachePackages = () => __awaiter(void 0, void 0, void 0, function* () { | const cachePackages = () => __awaiter(void 0, void 0, void 0, function* () { | ||||||
|     const state = core.getState(constants_1.State.CacheMatchedKey); |     const state = core.getState(constants_1.State.CacheMatchedKey); | ||||||
|     const primaryKey = core.getState(constants_1.State.CachePrimaryKey); |     const primaryKey = core.getState(constants_1.State.CachePrimaryKey); | ||||||
|     if (!primaryKey) { |     if (!primaryKey) { | ||||||
|         core.info('Primary key was not generated, not saving cache.'); |         core.info('Primary key was not generated, not saving cache.'); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|     const { 'global-packages': cachePath } = yield (0, cache_utils_1.getNuGetFolderPath)(); |     const { 'global-packages': cachePath } = yield (0, cache_utils_1.getNuGetFolderPath)(); | ||||||
|     if (!node_fs_1.default.existsSync(cachePath)) { |     if (!node_fs_1.default.existsSync(cachePath)) { | ||||||
|         throw new Error(`Cache folder path is retrieved for .NET CLI but doesn't exist on disk: ${cachePath}`); |         throw new Error(`Cache folder path is retrieved for .NET CLI but doesn't exist on disk: ${cachePath}`); | ||||||
|     } |     } | ||||||
|     if (primaryKey === state) { |     if (primaryKey === state) { | ||||||
|         core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); |         core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|     const cacheId = yield cache.saveCache([cachePath], primaryKey); |     const cacheId = yield cache.saveCache([cachePath], primaryKey); | ||||||
|     if (cacheId == -1) { |     if (cacheId == -1) { | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|     core.info(`Cache saved with the key: ${primaryKey}`); |     core.info(`Cache saved with the key: ${primaryKey}`); | ||||||
| }); | }); | ||||||
| run(); | run(); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /***/ }), | /***/ }), | ||||||
| @ -58569,114 +58569,114 @@ run(); | |||||||
| /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { | /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { | ||||||
| 
 | 
 | ||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||||||
|     if (k2 === undefined) k2 = k; |     if (k2 === undefined) k2 = k; | ||||||
|     var desc = Object.getOwnPropertyDescriptor(m, k); |     var desc = Object.getOwnPropertyDescriptor(m, k); | ||||||
|     if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { |     if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||||||
|       desc = { enumerable: true, get: function() { return m[k]; } }; |       desc = { enumerable: true, get: function() { return m[k]; } }; | ||||||
|     } |     } | ||||||
|     Object.defineProperty(o, k2, desc); |     Object.defineProperty(o, k2, desc); | ||||||
| }) : (function(o, m, k, k2) { | }) : (function(o, m, k, k2) { | ||||||
|     if (k2 === undefined) k2 = k; |     if (k2 === undefined) k2 = k; | ||||||
|     o[k2] = m[k]; |     o[k2] = m[k]; | ||||||
| })); | })); | ||||||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||||||
|     Object.defineProperty(o, "default", { enumerable: true, value: v }); |     Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||||||
| }) : function(o, v) { | }) : function(o, v) { | ||||||
|     o["default"] = v; |     o["default"] = v; | ||||||
| }); | }); | ||||||
| var __importStar = (this && this.__importStar) || function (mod) { | var __importStar = (this && this.__importStar) || function (mod) { | ||||||
|     if (mod && mod.__esModule) return mod; |     if (mod && mod.__esModule) return mod; | ||||||
|     var result = {}; |     var result = {}; | ||||||
|     if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); |     if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||||||
|     __setModuleDefault(result, mod); |     __setModuleDefault(result, mod); | ||||||
|     return result; |     return result; | ||||||
| }; | }; | ||||||
| var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||||||
|     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||||||
|     return new (P || (P = Promise))(function (resolve, reject) { |     return new (P || (P = Promise))(function (resolve, reject) { | ||||||
|         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } |         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||||||
|         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } |         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||||||
|         function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } |         function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||||||
|         step((generator = generator.apply(thisArg, _arguments || [])).next()); |         step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||||||
|     }); |     }); | ||||||
| }; | }; | ||||||
| Object.defineProperty(exports, "__esModule", ({ value: true })); | Object.defineProperty(exports, "__esModule", ({ value: true })); | ||||||
| exports.isCacheFeatureAvailable = exports.getNuGetFolderPath = void 0; | exports.isCacheFeatureAvailable = exports.getNuGetFolderPath = void 0; | ||||||
| const cache = __importStar(__nccwpck_require__(7799)); | const cache = __importStar(__nccwpck_require__(7799)); | ||||||
| const core = __importStar(__nccwpck_require__(2186)); | const core = __importStar(__nccwpck_require__(2186)); | ||||||
| const exec = __importStar(__nccwpck_require__(1514)); | const exec = __importStar(__nccwpck_require__(1514)); | ||||||
| const constants_1 = __nccwpck_require__(9042); | const constants_1 = __nccwpck_require__(9042); | ||||||
| /** | /** | ||||||
|  * Get NuGet global packages, cache, and temp folders from .NET CLI. |  * Get NuGet global packages, cache, and temp folders from .NET CLI. | ||||||
|  * @returns (Folder Name)-(Path) mappings |  * @returns (Folder Name)-(Path) mappings | ||||||
|  * @see https://docs.microsoft.com/nuget/consume-packages/managing-the-global-packages-and-cache-folders
 |  * @see https://docs.microsoft.com/nuget/consume-packages/managing-the-global-packages-and-cache-folders
 | ||||||
|  * @example |  * @example | ||||||
|  * Windows |  * Windows | ||||||
|  * ```json
 |  * ```json
 | ||||||
|  * { |  * { | ||||||
|  *   "http-cache": "C:\\Users\\user1\\AppData\\Local\\NuGet\\v3-cache", |  *   "http-cache": "C:\\Users\\user1\\AppData\\Local\\NuGet\\v3-cache", | ||||||
|  *   "global-packages": "C:\\Users\\user1\\.nuget\\packages\\", |  *   "global-packages": "C:\\Users\\user1\\.nuget\\packages\\", | ||||||
|  *   "temp": "C:\\Users\\user1\\AppData\\Local\\Temp\\NuGetScratch", |  *   "temp": "C:\\Users\\user1\\AppData\\Local\\Temp\\NuGetScratch", | ||||||
|  *   "plugins-cache": "C:\\Users\\user1\\AppData\\Local\\NuGet\\plugins-cache" |  *   "plugins-cache": "C:\\Users\\user1\\AppData\\Local\\NuGet\\plugins-cache" | ||||||
|  * } |  * } | ||||||
|  * ``` |  * ``` | ||||||
|  * |  * | ||||||
|  * Mac/Linux |  * Mac/Linux | ||||||
|  * ```json
 |  * ```json
 | ||||||
|  * { |  * { | ||||||
|  *   "http-cache": "/home/user1/.local/share/NuGet/v3-cache", |  *   "http-cache": "/home/user1/.local/share/NuGet/v3-cache", | ||||||
|  *   "global-packages": "/home/user1/.nuget/packages/", |  *   "global-packages": "/home/user1/.nuget/packages/", | ||||||
|  *   "temp": "/tmp/NuGetScratch", |  *   "temp": "/tmp/NuGetScratch", | ||||||
|  *   "plugins-cache": "/home/user1/.local/share/NuGet/plugins-cache" |  *   "plugins-cache": "/home/user1/.local/share/NuGet/plugins-cache" | ||||||
|  * } |  * } | ||||||
|  * ``` |  * ``` | ||||||
|  */ |  */ | ||||||
| const getNuGetFolderPath = () => __awaiter(void 0, void 0, void 0, function* () { | const getNuGetFolderPath = () => __awaiter(void 0, void 0, void 0, function* () { | ||||||
|     const { stdout, stderr, exitCode } = yield exec.getExecOutput(constants_1.cliCommand, undefined, { ignoreReturnCode: true, silent: true }); |     const { stdout, stderr, exitCode } = yield exec.getExecOutput(constants_1.cliCommand, undefined, { ignoreReturnCode: true, silent: true }); | ||||||
|     if (exitCode) { |     if (exitCode) { | ||||||
|         throw new Error(!stderr.trim() |         throw new Error(!stderr.trim() | ||||||
|             ? `The '${constants_1.cliCommand}' command failed with exit code: ${exitCode}` |             ? `The '${constants_1.cliCommand}' command failed with exit code: ${exitCode}` | ||||||
|             : stderr); |             : stderr); | ||||||
|     } |     } | ||||||
|     const result = { |     const result = { | ||||||
|         'http-cache': '', |         'http-cache': '', | ||||||
|         'global-packages': '', |         'global-packages': '', | ||||||
|         temp: '', |         temp: '', | ||||||
|         'plugins-cache': '' |         'plugins-cache': '' | ||||||
|     }; |     }; | ||||||
|     const regex = /(?:^|\s)(?<key>[a-z-]+): (?<path>.+[/\\].+)$/gm; |     const regex = /(?:^|\s)(?<key>[a-z-]+): (?<path>.+[/\\].+)$/gm; | ||||||
|     let match; |     let match; | ||||||
|     while ((match = regex.exec(stdout)) !== null) { |     while ((match = regex.exec(stdout)) !== null) { | ||||||
|         const key = match.groups.key; |         const key = match.groups.key; | ||||||
|         if (key in result) { |         if (key in result) { | ||||||
|             result[key] = match.groups.path; |             result[key] = match.groups.path; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     return result; |     return result; | ||||||
| }); | }); | ||||||
| exports.getNuGetFolderPath = getNuGetFolderPath; | exports.getNuGetFolderPath = getNuGetFolderPath; | ||||||
| function isCacheFeatureAvailable() { | function isCacheFeatureAvailable() { | ||||||
|     if (cache.isFeatureAvailable()) { |     if (cache.isFeatureAvailable()) { | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|     if (isGhes()) { |     if (isGhes()) { | ||||||
|         core.warning('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'); |         core.warning('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'); | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|     core.warning('The runner was not able to contact the cache service. Caching will be skipped'); |     core.warning('The runner was not able to contact the cache service. Caching will be skipped'); | ||||||
|     return false; |     return false; | ||||||
| } | } | ||||||
| exports.isCacheFeatureAvailable = isCacheFeatureAvailable; | exports.isCacheFeatureAvailable = isCacheFeatureAvailable; | ||||||
| /** | /** | ||||||
|  * Returns this action runs on GitHub Enterprise Server or not. |  * Returns this action runs on GitHub Enterprise Server or not. | ||||||
|  * (port from https://github.com/actions/toolkit/blob/457303960f03375db6f033e214b9f90d79c3fe5c/packages/cache/src/internal/cacheUtils.ts#L134)
 |  * (port from https://github.com/actions/toolkit/blob/457303960f03375db6f033e214b9f90d79c3fe5c/packages/cache/src/internal/cacheUtils.ts#L134)
 | ||||||
|  */ |  */ | ||||||
| function isGhes() { | function isGhes() { | ||||||
|     const url = process.env['GITHUB_SERVER_URL'] || 'https://github.com'; |     const url = process.env['GITHUB_SERVER_URL'] || 'https://github.com'; | ||||||
|     return new URL(url).hostname.toUpperCase() !== 'GITHUB.COM'; |     return new URL(url).hostname.toUpperCase() !== 'GITHUB.COM'; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /***/ }), | /***/ }), | ||||||
| @ -58685,26 +58685,26 @@ function isGhes() { | |||||||
| /***/ ((__unused_webpack_module, exports) => { | /***/ ((__unused_webpack_module, exports) => { | ||||||
| 
 | 
 | ||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| Object.defineProperty(exports, "__esModule", ({ value: true })); | Object.defineProperty(exports, "__esModule", ({ value: true })); | ||||||
| exports.Outputs = exports.State = exports.cliCommand = exports.lockFilePatterns = void 0; | exports.Outputs = exports.State = exports.cliCommand = exports.lockFilePatterns = void 0; | ||||||
| /** NuGet lock file patterns */ | /** NuGet lock file patterns */ | ||||||
| exports.lockFilePatterns = ['packages.lock.json']; | exports.lockFilePatterns = ['packages.lock.json']; | ||||||
| /** | /** | ||||||
|  * .NET CLI command to list local NuGet resources. |  * .NET CLI command to list local NuGet resources. | ||||||
|  * @see https://docs.microsoft.com/dotnet/core/tools/dotnet-nuget-locals
 |  * @see https://docs.microsoft.com/dotnet/core/tools/dotnet-nuget-locals
 | ||||||
|  */ |  */ | ||||||
| exports.cliCommand = 'dotnet nuget locals all --list --force-english-output'; | exports.cliCommand = 'dotnet nuget locals all --list --force-english-output'; | ||||||
| var State; | var State; | ||||||
| (function (State) { | (function (State) { | ||||||
|     State["CachePrimaryKey"] = "CACHE_KEY"; |     State["CachePrimaryKey"] = "CACHE_KEY"; | ||||||
|     State["CacheMatchedKey"] = "CACHE_RESULT"; |     State["CacheMatchedKey"] = "CACHE_RESULT"; | ||||||
| })(State = exports.State || (exports.State = {})); | })(State = exports.State || (exports.State = {})); | ||||||
| var Outputs; | var Outputs; | ||||||
| (function (Outputs) { | (function (Outputs) { | ||||||
|     Outputs["CacheHit"] = "cache-hit"; |     Outputs["CacheHit"] = "cache-hit"; | ||||||
|     Outputs["DotnetVersion"] = "dotnet-version"; |     Outputs["DotnetVersion"] = "dotnet-version"; | ||||||
| })(Outputs = exports.Outputs || (exports.Outputs = {})); | })(Outputs = exports.Outputs || (exports.Outputs = {})); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /***/ }), | /***/ }), | ||||||
|  | |||||||
							
								
								
									
										218
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										218
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							| @ -71171,9 +71171,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge | |||||||
| var __importDefault = (this && this.__importDefault) || function (mod) { | var __importDefault = (this && this.__importDefault) || function (mod) { | ||||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; |     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||||
| }; | }; | ||||||
| var _a; |  | ||||||
| Object.defineProperty(exports, "__esModule", ({ value: true })); | Object.defineProperty(exports, "__esModule", ({ value: true })); | ||||||
| exports.DotnetCoreInstaller = exports.DotnetVersionResolver = void 0; | exports.DotnetCoreInstaller = exports.DotnetInstallDir = exports.DotnetInstallScript = exports.DotnetVersionResolver = void 0; | ||||||
| // Load tempDirectory before it gets wiped by tool-cache
 | // Load tempDirectory before it gets wiped by tool-cache
 | ||||||
| const core = __importStar(__nccwpck_require__(2186)); | const core = __importStar(__nccwpck_require__(2186)); | ||||||
| const exec = __importStar(__nccwpck_require__(1514)); | const exec = __importStar(__nccwpck_require__(1514)); | ||||||
| @ -71208,8 +71207,8 @@ class DotnetVersionResolver { | |||||||
|         return /^\d+$/.test(versionTag); |         return /^\d+$/.test(versionTag); | ||||||
|     } |     } | ||||||
|     isLatestPatchSyntax() { |     isLatestPatchSyntax() { | ||||||
|         var _b, _c; |         var _a, _b; | ||||||
|         const majorTag = (_c = (_b = this.inputVersion.match(/^(?<majorTag>\d+)\.\d+\.\d{1}x{2}$/)) === null || _b === void 0 ? void 0 : _b.groups) === null || _c === void 0 ? void 0 : _c.majorTag; |         const majorTag = (_b = (_a = this.inputVersion.match(/^(?<majorTag>\d+)\.\d+\.\d{1}x{2}$/)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.majorTag; | ||||||
|         if (majorTag && |         if (majorTag && | ||||||
|             parseInt(majorTag) < LATEST_PATCH_SYNTAX_MINIMAL_MAJOR_TAG) { |             parseInt(majorTag) < LATEST_PATCH_SYNTAX_MINIMAL_MAJOR_TAG) { | ||||||
|             throw new Error(`The 'dotnet-version' was supplied in invalid format: ${this.inputVersion}! The A.B.Cxx syntax is available since the .NET 5.0 release.`); |             throw new Error(`The 'dotnet-version' was supplied in invalid format: ${this.inputVersion}! The A.B.Cxx syntax is available since the .NET 5.0 release.`); | ||||||
| @ -71241,7 +71240,7 @@ class DotnetVersionResolver { | |||||||
|                 parseInt(major) >= QUALITY_INPUT_MINIMAL_MAJOR_TAG ? true : false; |                 parseInt(major) >= QUALITY_INPUT_MINIMAL_MAJOR_TAG ? true : false; | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|     createDotNetVersion() { |     createDotnetVersion() { | ||||||
|         return __awaiter(this, void 0, void 0, function* () { |         return __awaiter(this, void 0, void 0, function* () { | ||||||
|             yield this.resolveVersionInput(); |             yield this.resolveVersionInput(); | ||||||
|             if (!this.resolvedArgument.type) { |             if (!this.resolvedArgument.type) { | ||||||
| @ -71264,7 +71263,7 @@ class DotnetVersionResolver { | |||||||
|                 allowRetries: true, |                 allowRetries: true, | ||||||
|                 maxRetries: 3 |                 maxRetries: 3 | ||||||
|             }); |             }); | ||||||
|             const response = yield httpClient.getJson(DotnetVersionResolver.DotNetCoreIndexUrl); |             const response = yield httpClient.getJson(DotnetVersionResolver.DotnetCoreIndexUrl); | ||||||
|             const result = response.result || {}; |             const result = response.result || {}; | ||||||
|             const releasesInfo = result['releases-index']; |             const releasesInfo = result['releases-index']; | ||||||
|             const releaseInfo = releasesInfo.find(info => { |             const releaseInfo = releasesInfo.find(info => { | ||||||
| @ -71272,99 +71271,124 @@ class DotnetVersionResolver { | |||||||
|                 return sdkParts[0] === majorTag; |                 return sdkParts[0] === majorTag; | ||||||
|             }); |             }); | ||||||
|             if (!releaseInfo) { |             if (!releaseInfo) { | ||||||
|                 throw new Error(`Could not find info for version with major tag: "${majorTag}" at ${DotnetVersionResolver.DotNetCoreIndexUrl}`); |                 throw new Error(`Could not find info for version with major tag: "${majorTag}" at ${DotnetVersionResolver.DotnetCoreIndexUrl}`); | ||||||
|             } |             } | ||||||
|             return releaseInfo['channel-version']; |             return releaseInfo['channel-version']; | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| exports.DotnetVersionResolver = DotnetVersionResolver; | exports.DotnetVersionResolver = DotnetVersionResolver; | ||||||
| DotnetVersionResolver.DotNetCoreIndexUrl = 'https://dotnetcli.azureedge.net/dotnet/release-metadata/releases-index.json'; | DotnetVersionResolver.DotnetCoreIndexUrl = 'https://dotnetcli.azureedge.net/dotnet/release-metadata/releases-index.json'; | ||||||
| class DotnetCoreInstaller { | class DotnetInstallScript { | ||||||
|     constructor(version, quality) { |     constructor() { | ||||||
|         this.version = version; |         this.scriptName = utils_1.IS_WINDOWS ? 'install-dotnet.ps1' : 'install-dotnet.sh'; | ||||||
|         this.quality = quality; |         this.scriptArguments = []; | ||||||
|  |         this.escapedScript = path_1.default | ||||||
|  |             .join(__dirname, '..', '..', 'externals', this.scriptName) | ||||||
|  |             .replace(/'/g, "''"); | ||||||
|  |         if (utils_1.IS_WINDOWS) { | ||||||
|  |             this.setupScriptPowershell(); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         this.setupScriptBash(); | ||||||
|     } |     } | ||||||
|  |     setupScriptPowershell() { | ||||||
|  |         this.scriptArguments = [ | ||||||
|  |             '-NoLogo', | ||||||
|  |             '-Sta', | ||||||
|  |             '-NoProfile', | ||||||
|  |             '-NonInteractive', | ||||||
|  |             '-ExecutionPolicy', | ||||||
|  |             'Unrestricted', | ||||||
|  |             '-Command' | ||||||
|  |         ]; | ||||||
|  |         this.scriptArguments.push('&', `'${this.escapedScript}'`); | ||||||
|  |         if (process.env['https_proxy'] != null) { | ||||||
|  |             this.scriptArguments.push(`-ProxyAddress ${process.env['https_proxy']}`); | ||||||
|  |         } | ||||||
|  |         // This is not currently an option
 | ||||||
|  |         if (process.env['no_proxy'] != null) { | ||||||
|  |             this.scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     setupScriptBash() { | ||||||
|  |         (0, fs_1.chmodSync)(this.escapedScript, '777'); | ||||||
|  |     } | ||||||
|  |     getScriptPath() { | ||||||
|  |         return __awaiter(this, void 0, void 0, function* () { | ||||||
|  |             if (utils_1.IS_WINDOWS) { | ||||||
|  |                 return (yield io.which('pwsh', false)) || io.which('powershell', true); | ||||||
|  |             } | ||||||
|  |             return io.which(this.escapedScript, true); | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |     useArguments(...args) { | ||||||
|  |         this.scriptArguments.push(...args); | ||||||
|  |         return this; | ||||||
|  |     } | ||||||
|  |     useVersion(dotnetVersion, quality) { | ||||||
|  |         if (dotnetVersion.type) { | ||||||
|  |             this.useArguments(dotnetVersion.type, dotnetVersion.value); | ||||||
|  |         } | ||||||
|  |         if (quality && !dotnetVersion.qualityFlag) { | ||||||
|  |             core.warning(`The '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 tag is higher than 5. You specified: ${dotnetVersion.value}. 'dotnet-quality' input is ignored.`); | ||||||
|  |             return this; | ||||||
|  |         } | ||||||
|  |         if (quality) { | ||||||
|  |             this.useArguments(utils_1.IS_WINDOWS ? '-Quality' : '--quality', quality); | ||||||
|  |         } | ||||||
|  |         return this; | ||||||
|  |     } | ||||||
|  |     execute() { | ||||||
|  |         return __awaiter(this, void 0, void 0, function* () { | ||||||
|  |             const getExecOutputOptions = { | ||||||
|  |                 ignoreReturnCode: true, | ||||||
|  |                 env: process.env | ||||||
|  |             }; | ||||||
|  |             return exec.getExecOutput(`"${yield this.getScriptPath()}"`, this.scriptArguments, getExecOutputOptions); | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | exports.DotnetInstallScript = DotnetInstallScript; | ||||||
|  | class DotnetInstallDir { | ||||||
|     static convertInstallPathToAbsolute(installDir) { |     static convertInstallPathToAbsolute(installDir) { | ||||||
|         let transformedPath; |         if (path_1.default.isAbsolute(installDir)) | ||||||
|         if (path_1.default.isAbsolute(installDir)) { |             return path_1.default.normalize(installDir); | ||||||
|             transformedPath = installDir; |         const transformedPath = installDir.startsWith('~') | ||||||
|         } |             ? path_1.default.join(os_1.default.homedir(), installDir.slice(1)) | ||||||
|         else { |             : path_1.default.join(process.cwd(), installDir); | ||||||
|             transformedPath = installDir.startsWith('~') |  | ||||||
|                 ? path_1.default.join(os_1.default.homedir(), installDir.slice(1)) |  | ||||||
|                 : (transformedPath = path_1.default.join(process.cwd(), installDir)); |  | ||||||
|         } |  | ||||||
|         return path_1.default.normalize(transformedPath); |         return path_1.default.normalize(transformedPath); | ||||||
|     } |     } | ||||||
|     static addToPath() { |     static addToPath() { | ||||||
|         core.addPath(process.env['DOTNET_INSTALL_DIR']); |         core.addPath(process.env['DOTNET_INSTALL_DIR']); | ||||||
|         core.exportVariable('DOTNET_ROOT', process.env['DOTNET_INSTALL_DIR']); |         core.exportVariable('DOTNET_ROOT', process.env['DOTNET_INSTALL_DIR']); | ||||||
|     } |     } | ||||||
|     setQuality(dotnetVersion, scriptArguments) { |     static setEnvironmentVariable() { | ||||||
|         const option = utils_1.IS_WINDOWS ? '-Quality' : '--quality'; |         process.env['DOTNET_INSTALL_DIR'] = DotnetInstallDir.dirPath; | ||||||
|         if (dotnetVersion.qualityFlag) { |     } | ||||||
|             scriptArguments.push(option, this.quality); | } | ||||||
|         } | exports.DotnetInstallDir = DotnetInstallDir; | ||||||
|         else { | DotnetInstallDir.default = { | ||||||
|             core.warning(`The '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 tag is higher than 5. You specified: ${this.version}. 'dotnet-quality' input is ignored.`); |     linux: '/usr/share/dotnet', | ||||||
|         } |     mac: path_1.default.join(process.env['HOME'] + '', '.dotnet'), | ||||||
|  |     windows: path_1.default.join(process.env['PROGRAMFILES'] + '', 'dotnet') | ||||||
|  | }; | ||||||
|  | DotnetInstallDir.dirPath = process.env['DOTNET_INSTALL_DIR'] | ||||||
|  |     ? DotnetInstallDir.convertInstallPathToAbsolute(process.env['DOTNET_INSTALL_DIR']) | ||||||
|  |     : DotnetInstallDir.default[utils_1.PLATFORM]; | ||||||
|  | class DotnetCoreInstaller { | ||||||
|  |     constructor(version, quality) { | ||||||
|  |         this.version = version; | ||||||
|  |         this.quality = quality; | ||||||
|     } |     } | ||||||
|     installDotnet() { |     installDotnet() { | ||||||
|         return __awaiter(this, void 0, void 0, function* () { |         return __awaiter(this, void 0, void 0, function* () { | ||||||
|             const windowsDefaultOptions = [ |  | ||||||
|                 '-NoLogo', |  | ||||||
|                 '-Sta', |  | ||||||
|                 '-NoProfile', |  | ||||||
|                 '-NonInteractive', |  | ||||||
|                 '-ExecutionPolicy', |  | ||||||
|                 'Unrestricted', |  | ||||||
|                 '-Command' |  | ||||||
|             ]; |  | ||||||
|             const scriptName = utils_1.IS_WINDOWS ? 'install-dotnet.ps1' : 'install-dotnet.sh'; |  | ||||||
|             const escapedScript = path_1.default |  | ||||||
|                 .join(__dirname, '..', '..', 'externals', scriptName) |  | ||||||
|                 .replace(/'/g, "''"); |  | ||||||
|             let scriptArguments; |  | ||||||
|             let scriptPath = ''; |  | ||||||
|             const versionResolver = new DotnetVersionResolver(this.version); |             const versionResolver = new DotnetVersionResolver(this.version); | ||||||
|             const dotnetVersion = yield versionResolver.createDotNetVersion(); |             const dotnetVersion = yield versionResolver.createDotnetVersion(); | ||||||
|             if (utils_1.IS_WINDOWS) { |             const installScript = new DotnetInstallScript() | ||||||
|                 scriptArguments = ['&', `'${escapedScript}'`]; |                 .useArguments(utils_1.IS_WINDOWS ? '-SkipNonVersionedFiles' : '--skip-non-versioned-files') | ||||||
|                 if (dotnetVersion.type) { |                 .useVersion(dotnetVersion, this.quality); | ||||||
|                     scriptArguments.push(dotnetVersion.type, dotnetVersion.value); |             const { exitCode, stderr, stdout } = yield installScript.execute(); | ||||||
|                 } |  | ||||||
|                 if (this.quality) { |  | ||||||
|                     this.setQuality(dotnetVersion, scriptArguments); |  | ||||||
|                 } |  | ||||||
|                 if (process.env['https_proxy'] != null) { |  | ||||||
|                     scriptArguments.push(`-ProxyAddress ${process.env['https_proxy']}`); |  | ||||||
|                 } |  | ||||||
|                 // This is not currently an option
 |  | ||||||
|                 if (process.env['no_proxy'] != null) { |  | ||||||
|                     scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`); |  | ||||||
|                 } |  | ||||||
|                 scriptPath = |  | ||||||
|                     (yield io.which('pwsh', false)) || (yield io.which('powershell', true)); |  | ||||||
|                 scriptArguments = windowsDefaultOptions.concat(scriptArguments); |  | ||||||
|             } |  | ||||||
|             else { |  | ||||||
|                 (0, fs_1.chmodSync)(escapedScript, '777'); |  | ||||||
|                 scriptPath = yield io.which(escapedScript, true); |  | ||||||
|                 scriptArguments = []; |  | ||||||
|                 if (dotnetVersion.type) { |  | ||||||
|                     scriptArguments.push(dotnetVersion.type, dotnetVersion.value); |  | ||||||
|                 } |  | ||||||
|                 if (this.quality) { |  | ||||||
|                     this.setQuality(dotnetVersion, scriptArguments); |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
 |  | ||||||
|             const getExecOutputOptions = { |  | ||||||
|                 ignoreReturnCode: true, |  | ||||||
|                 env: process.env |  | ||||||
|             }; |  | ||||||
|             const { exitCode, stdout, stderr } = yield exec.getExecOutput(`"${scriptPath}"`, scriptArguments, getExecOutputOptions); |  | ||||||
|             if (exitCode) { |             if (exitCode) { | ||||||
|                 throw new Error(`Failed to install dotnet, exit code: ${exitCode}. ${stderr}`); |                 throw new Error(`Failed to install dotnet, exit code: ${exitCode}. ${stderr}`); | ||||||
|             } |             } | ||||||
| @ -71382,26 +71406,8 @@ class DotnetCoreInstaller { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| exports.DotnetCoreInstaller = DotnetCoreInstaller; | exports.DotnetCoreInstaller = DotnetCoreInstaller; | ||||||
| _a = DotnetCoreInstaller; |  | ||||||
| (() => { | (() => { | ||||||
|     const installationDirectoryWindows = path_1.default.join(process.env['PROGRAMFILES'] + '', 'dotnet'); |     DotnetInstallDir.setEnvironmentVariable(); | ||||||
|     const installationDirectoryLinux = '/usr/share/dotnet'; |  | ||||||
|     const installationDirectoryMac = path_1.default.join(process.env['HOME'] + '', '.dotnet'); |  | ||||||
|     const dotnetInstallDir = process.env['DOTNET_INSTALL_DIR']; |  | ||||||
|     if (dotnetInstallDir) { |  | ||||||
|         process.env['DOTNET_INSTALL_DIR'] = |  | ||||||
|             _a.convertInstallPathToAbsolute(dotnetInstallDir); |  | ||||||
|     } |  | ||||||
|     else { |  | ||||||
|         if (utils_1.IS_WINDOWS) { |  | ||||||
|             process.env['DOTNET_INSTALL_DIR'] = installationDirectoryWindows; |  | ||||||
|         } |  | ||||||
|         else { |  | ||||||
|             process.env['DOTNET_INSTALL_DIR'] = utils_1.IS_LINUX |  | ||||||
|                 ? installationDirectoryLinux |  | ||||||
|                 : installationDirectoryMac; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| })(); | })(); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -71510,7 +71516,7 @@ function run() { | |||||||
|                     const installedVersion = yield dotnetInstaller.installDotnet(); |                     const installedVersion = yield dotnetInstaller.installDotnet(); | ||||||
|                     installedDotnetVersions.push(installedVersion); |                     installedDotnetVersions.push(installedVersion); | ||||||
|                 } |                 } | ||||||
|                 installer_1.DotnetCoreInstaller.addToPath(); |                 installer_1.DotnetInstallDir.addToPath(); | ||||||
|             } |             } | ||||||
|             const sourceUrl = core.getInput('source-url'); |             const sourceUrl = core.getInput('source-url'); | ||||||
|             const configFile = core.getInput('config-file'); |             const configFile = core.getInput('config-file'); | ||||||
| @ -71576,9 +71582,15 @@ run(); | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| Object.defineProperty(exports, "__esModule", ({ value: true })); | Object.defineProperty(exports, "__esModule", ({ value: true })); | ||||||
| exports.IS_LINUX = exports.IS_WINDOWS = void 0; | exports.PLATFORM = exports.IS_WINDOWS = void 0; | ||||||
| exports.IS_WINDOWS = process.platform === 'win32'; | exports.IS_WINDOWS = process.platform === 'win32'; | ||||||
| exports.IS_LINUX = process.platform === 'linux'; | exports.PLATFORM = (() => { | ||||||
|  |     if (process.platform === 'win32') | ||||||
|  |         return 'windows'; | ||||||
|  |     if (process.platform === 'linux') | ||||||
|  |         return 'linux'; | ||||||
|  |     return 'mac'; | ||||||
|  | })(); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /***/ }), | /***/ }), | ||||||
|  | |||||||
							
								
								
									
										241
									
								
								src/installer.ts
									
									
									
									
									
								
							
							
						
						
									
										241
									
								
								src/installer.ts
									
									
									
									
									
								
							| @ -7,7 +7,7 @@ import {chmodSync} from 'fs'; | |||||||
| import path from 'path'; | import path from 'path'; | ||||||
| import os from 'os'; | import os from 'os'; | ||||||
| import semver from 'semver'; | import semver from 'semver'; | ||||||
| import {IS_LINUX, IS_WINDOWS} from './utils'; | import {IS_WINDOWS, PLATFORM} from './utils'; | ||||||
| import {QualityOptions} from './setup-dotnet'; | import {QualityOptions} from './setup-dotnet'; | ||||||
| 
 | 
 | ||||||
| export interface DotnetVersion { | export interface DotnetVersion { | ||||||
| @ -81,7 +81,7 @@ export class DotnetVersionResolver { | |||||||
|       parseInt(major) >= QUALITY_INPUT_MINIMAL_MAJOR_TAG ? true : false; |       parseInt(major) >= QUALITY_INPUT_MINIMAL_MAJOR_TAG ? true : false; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   public async createDotNetVersion(): Promise<DotnetVersion> { |   public async createDotnetVersion(): Promise<DotnetVersion> { | ||||||
|     await this.resolveVersionInput(); |     await this.resolveVersionInput(); | ||||||
|     if (!this.resolvedArgument.type) { |     if (!this.resolvedArgument.type) { | ||||||
|       return this.resolvedArgument; |       return this.resolvedArgument; | ||||||
| @ -102,7 +102,7 @@ export class DotnetVersionResolver { | |||||||
|       maxRetries: 3 |       maxRetries: 3 | ||||||
|     }); |     }); | ||||||
|     const response = await httpClient.getJson<any>( |     const response = await httpClient.getJson<any>( | ||||||
|       DotnetVersionResolver.DotNetCoreIndexUrl |       DotnetVersionResolver.DotnetCoreIndexUrl | ||||||
|     ); |     ); | ||||||
|     const result = response.result || {}; |     const result = response.result || {}; | ||||||
|     const releasesInfo: any[] = result['releases-index']; |     const releasesInfo: any[] = result['releases-index']; | ||||||
| @ -114,85 +114,37 @@ export class DotnetVersionResolver { | |||||||
| 
 | 
 | ||||||
|     if (!releaseInfo) { |     if (!releaseInfo) { | ||||||
|       throw new Error( |       throw new Error( | ||||||
|         `Could not find info for version with major tag: "${majorTag}" at ${DotnetVersionResolver.DotNetCoreIndexUrl}` |         `Could not find info for version with major tag: "${majorTag}" at ${DotnetVersionResolver.DotnetCoreIndexUrl}` | ||||||
|       ); |       ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return releaseInfo['channel-version']; |     return releaseInfo['channel-version']; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   static DotNetCoreIndexUrl = |   static DotnetCoreIndexUrl = | ||||||
|     'https://dotnetcli.azureedge.net/dotnet/release-metadata/releases-index.json'; |     'https://dotnetcli.azureedge.net/dotnet/release-metadata/releases-index.json'; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export class DotnetCoreInstaller { | export class DotnetInstallScript { | ||||||
|   private version: string; |   private scriptName = IS_WINDOWS ? 'install-dotnet.ps1' : 'install-dotnet.sh'; | ||||||
|   private quality: QualityOptions; |   private escapedScript: string; | ||||||
|  |   private scriptArguments: string[] = []; | ||||||
| 
 | 
 | ||||||
|   static { |   constructor() { | ||||||
|     const installationDirectoryWindows = path.join( |     this.escapedScript = path | ||||||
|       process.env['PROGRAMFILES'] + '', |       .join(__dirname, '..', '..', 'externals', this.scriptName) | ||||||
|       'dotnet' |       .replace(/'/g, "''"); | ||||||
|     ); | 
 | ||||||
|     const installationDirectoryLinux = '/usr/share/dotnet'; |     if (IS_WINDOWS) { | ||||||
|     const installationDirectoryMac = path.join( |       this.setupScriptPowershell(); | ||||||
|       process.env['HOME'] + '', |       return; | ||||||
|       '.dotnet' |  | ||||||
|     ); |  | ||||||
|     const dotnetInstallDir: string | undefined = |  | ||||||
|       process.env['DOTNET_INSTALL_DIR']; |  | ||||||
|     if (dotnetInstallDir) { |  | ||||||
|       process.env['DOTNET_INSTALL_DIR'] = |  | ||||||
|         this.convertInstallPathToAbsolute(dotnetInstallDir); |  | ||||||
|     } else { |  | ||||||
|       if (IS_WINDOWS) { |  | ||||||
|         process.env['DOTNET_INSTALL_DIR'] = installationDirectoryWindows; |  | ||||||
|       } else { |  | ||||||
|         process.env['DOTNET_INSTALL_DIR'] = IS_LINUX |  | ||||||
|           ? installationDirectoryLinux |  | ||||||
|           : installationDirectoryMac; |  | ||||||
|       } |  | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     this.setupScriptBash(); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   constructor(version: string, quality: QualityOptions) { |   private setupScriptPowershell() { | ||||||
|     this.version = version; |     this.scriptArguments = [ | ||||||
|     this.quality = quality; |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   private static convertInstallPathToAbsolute(installDir: string): string { |  | ||||||
|     let transformedPath; |  | ||||||
|     if (path.isAbsolute(installDir)) { |  | ||||||
|       transformedPath = installDir; |  | ||||||
|     } else { |  | ||||||
|       transformedPath = installDir.startsWith('~') |  | ||||||
|         ? path.join(os.homedir(), installDir.slice(1)) |  | ||||||
|         : (transformedPath = path.join(process.cwd(), installDir)); |  | ||||||
|     } |  | ||||||
|     return path.normalize(transformedPath); |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   static addToPath() { |  | ||||||
|     core.addPath(process.env['DOTNET_INSTALL_DIR']!); |  | ||||||
|     core.exportVariable('DOTNET_ROOT', process.env['DOTNET_INSTALL_DIR']); |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   private setQuality( |  | ||||||
|     dotnetVersion: DotnetVersion, |  | ||||||
|     scriptArguments: string[] |  | ||||||
|   ): void { |  | ||||||
|     const option = IS_WINDOWS ? '-Quality' : '--quality'; |  | ||||||
|     if (dotnetVersion.qualityFlag) { |  | ||||||
|       scriptArguments.push(option, this.quality); |  | ||||||
|     } else { |  | ||||||
|       core.warning( |  | ||||||
|         `The '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 tag is higher than 5. You specified: ${this.version}. 'dotnet-quality' input is ignored.` |  | ||||||
|       ); |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   public async installDotnet(): Promise<string | null> { |  | ||||||
|     const windowsDefaultOptions = [ |  | ||||||
|       '-NoLogo', |       '-NoLogo', | ||||||
|       '-Sta', |       '-Sta', | ||||||
|       '-NoProfile', |       '-NoProfile', | ||||||
| @ -201,61 +153,120 @@ export class DotnetCoreInstaller { | |||||||
|       'Unrestricted', |       'Unrestricted', | ||||||
|       '-Command' |       '-Command' | ||||||
|     ]; |     ]; | ||||||
|     const scriptName = IS_WINDOWS ? 'install-dotnet.ps1' : 'install-dotnet.sh'; |  | ||||||
|     const escapedScript = path |  | ||||||
|       .join(__dirname, '..', '..', 'externals', scriptName) |  | ||||||
|       .replace(/'/g, "''"); |  | ||||||
|     let scriptArguments: string[]; |  | ||||||
|     let scriptPath = ''; |  | ||||||
| 
 | 
 | ||||||
|     const versionResolver = new DotnetVersionResolver(this.version); |     this.scriptArguments.push('&', `'${this.escapedScript}'`); | ||||||
|     const dotnetVersion = await versionResolver.createDotNetVersion(); |  | ||||||
| 
 | 
 | ||||||
|     if (IS_WINDOWS) { |     if (process.env['https_proxy'] != null) { | ||||||
|       scriptArguments = ['&', `'${escapedScript}'`]; |       this.scriptArguments.push(`-ProxyAddress ${process.env['https_proxy']}`); | ||||||
| 
 |  | ||||||
|       if (dotnetVersion.type) { |  | ||||||
|         scriptArguments.push(dotnetVersion.type, dotnetVersion.value); |  | ||||||
|       } |  | ||||||
| 
 |  | ||||||
|       if (this.quality) { |  | ||||||
|         this.setQuality(dotnetVersion, scriptArguments); |  | ||||||
|       } |  | ||||||
| 
 |  | ||||||
|       if (process.env['https_proxy'] != null) { |  | ||||||
|         scriptArguments.push(`-ProxyAddress ${process.env['https_proxy']}`); |  | ||||||
|       } |  | ||||||
|       // This is not currently an option
 |  | ||||||
|       if (process.env['no_proxy'] != null) { |  | ||||||
|         scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`); |  | ||||||
|       } |  | ||||||
| 
 |  | ||||||
|       scriptPath = |  | ||||||
|         (await io.which('pwsh', false)) || (await io.which('powershell', true)); |  | ||||||
|       scriptArguments = windowsDefaultOptions.concat(scriptArguments); |  | ||||||
|     } else { |  | ||||||
|       chmodSync(escapedScript, '777'); |  | ||||||
|       scriptPath = await io.which(escapedScript, true); |  | ||||||
|       scriptArguments = []; |  | ||||||
| 
 |  | ||||||
|       if (dotnetVersion.type) { |  | ||||||
|         scriptArguments.push(dotnetVersion.type, dotnetVersion.value); |  | ||||||
|       } |  | ||||||
| 
 |  | ||||||
|       if (this.quality) { |  | ||||||
|         this.setQuality(dotnetVersion, scriptArguments); |  | ||||||
|       } |  | ||||||
|     } |     } | ||||||
|     // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
 |     // This is not currently an option
 | ||||||
|  |     if (process.env['no_proxy'] != null) { | ||||||
|  |       this.scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   private setupScriptBash() { | ||||||
|  |     chmodSync(this.escapedScript, '777'); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   private async getScriptPath() { | ||||||
|  |     if (IS_WINDOWS) { | ||||||
|  |       return (await io.which('pwsh', false)) || io.which('powershell', true); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     return io.which(this.escapedScript, true); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   public useArguments(...args: string[]) { | ||||||
|  |     this.scriptArguments.push(...args); | ||||||
|  |     return this; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   public useVersion(dotnetVersion: DotnetVersion, quality?: QualityOptions) { | ||||||
|  |     if (dotnetVersion.type) { | ||||||
|  |       this.useArguments(dotnetVersion.type, dotnetVersion.value); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (quality && !dotnetVersion.qualityFlag) { | ||||||
|  |       core.warning( | ||||||
|  |         `The '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 tag is higher than 5. You specified: ${dotnetVersion.value}. 'dotnet-quality' input is ignored.` | ||||||
|  |       ); | ||||||
|  |       return this; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (quality) { | ||||||
|  |       this.useArguments(IS_WINDOWS ? '-Quality' : '--quality', quality); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     return this; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   public async execute() { | ||||||
|     const getExecOutputOptions = { |     const getExecOutputOptions = { | ||||||
|       ignoreReturnCode: true, |       ignoreReturnCode: true, | ||||||
|       env: process.env as {string: string} |       env: process.env as {string: string} | ||||||
|     }; |     }; | ||||||
|     const {exitCode, stdout, stderr} = await exec.getExecOutput( | 
 | ||||||
|       `"${scriptPath}"`, |     return exec.getExecOutput( | ||||||
|       scriptArguments, |       `"${await this.getScriptPath()}"`, | ||||||
|  |       this.scriptArguments, | ||||||
|       getExecOutputOptions |       getExecOutputOptions | ||||||
|     ); |     ); | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export abstract class DotnetInstallDir { | ||||||
|  |   private static readonly default = { | ||||||
|  |     linux: '/usr/share/dotnet', | ||||||
|  |     mac: path.join(process.env['HOME'] + '', '.dotnet'), | ||||||
|  |     windows: path.join(process.env['PROGRAMFILES'] + '', 'dotnet') | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   public static readonly dirPath = process.env['DOTNET_INSTALL_DIR'] | ||||||
|  |     ? DotnetInstallDir.convertInstallPathToAbsolute( | ||||||
|  |         process.env['DOTNET_INSTALL_DIR'] | ||||||
|  |       ) | ||||||
|  |     : DotnetInstallDir.default[PLATFORM]; | ||||||
|  | 
 | ||||||
|  |   private static convertInstallPathToAbsolute(installDir: string): string { | ||||||
|  |     if (path.isAbsolute(installDir)) return path.normalize(installDir); | ||||||
|  | 
 | ||||||
|  |     const transformedPath = installDir.startsWith('~') | ||||||
|  |       ? path.join(os.homedir(), installDir.slice(1)) | ||||||
|  |       : path.join(process.cwd(), installDir); | ||||||
|  | 
 | ||||||
|  |     return path.normalize(transformedPath); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   public static addToPath() { | ||||||
|  |     core.addPath(process.env['DOTNET_INSTALL_DIR']!); | ||||||
|  |     core.exportVariable('DOTNET_ROOT', process.env['DOTNET_INSTALL_DIR']); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   public static setEnvironmentVariable() { | ||||||
|  |     process.env['DOTNET_INSTALL_DIR'] = DotnetInstallDir.dirPath; | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export class DotnetCoreInstaller { | ||||||
|  |   static { | ||||||
|  |     DotnetInstallDir.setEnvironmentVariable(); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   constructor(private version: string, private quality: QualityOptions) {} | ||||||
|  | 
 | ||||||
|  |   public async installDotnet(): Promise<string | null> { | ||||||
|  |     const versionResolver = new DotnetVersionResolver(this.version); | ||||||
|  |     const dotnetVersion = await versionResolver.createDotnetVersion(); | ||||||
|  | 
 | ||||||
|  |     const installScript = new DotnetInstallScript() | ||||||
|  |       .useArguments( | ||||||
|  |         IS_WINDOWS ? '-SkipNonVersionedFiles' : '--skip-non-versioned-files' | ||||||
|  |       ) | ||||||
|  |       .useVersion(dotnetVersion, this.quality); | ||||||
|  | 
 | ||||||
|  |     const {exitCode, stderr, stdout} = await installScript.execute(); | ||||||
|  | 
 | ||||||
|     if (exitCode) { |     if (exitCode) { | ||||||
|       throw new Error( |       throw new Error( | ||||||
|         `Failed to install dotnet, exit code: ${exitCode}. ${stderr}` |         `Failed to install dotnet, exit code: ${exitCode}. ${stderr}` | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| import * as core from '@actions/core'; | import * as core from '@actions/core'; | ||||||
| import {DotnetCoreInstaller} from './installer'; | import {DotnetCoreInstaller, DotnetInstallDir} from './installer'; | ||||||
| import * as fs from 'fs'; | import * as fs from 'fs'; | ||||||
| import path from 'path'; | import path from 'path'; | ||||||
| import semver from 'semver'; | import semver from 'semver'; | ||||||
| @ -72,7 +72,7 @@ export async function run() { | |||||||
|         const installedVersion = await dotnetInstaller.installDotnet(); |         const installedVersion = await dotnetInstaller.installDotnet(); | ||||||
|         installedDotnetVersions.push(installedVersion); |         installedDotnetVersions.push(installedVersion); | ||||||
|       } |       } | ||||||
|       DotnetCoreInstaller.addToPath(); |       DotnetInstallDir.addToPath(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const sourceUrl: string = core.getInput('source-url'); |     const sourceUrl: string = core.getInput('source-url'); | ||||||
|  | |||||||
| @ -1,2 +1,6 @@ | |||||||
| export const IS_WINDOWS = process.platform === 'win32'; | export const IS_WINDOWS = process.platform === 'win32'; | ||||||
| export const IS_LINUX = process.platform === 'linux'; | export const PLATFORM = ((): 'windows' | 'linux' | 'mac' => { | ||||||
|  |   if (process.platform === 'win32') return 'windows'; | ||||||
|  |   if (process.platform === 'linux') return 'linux'; | ||||||
|  |   return 'mac'; | ||||||
|  | })(); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user