mirror of
				https://github.com/actions/setup-dotnet.git
				synced 2025-11-04 07:33:45 +00:00 
			
		
		
		
	Add logic for processing DOTNET_INSTALL_DIR
This commit is contained in:
		
							parent
							
								
									6c6c8ddba4
								
							
						
					
					
						commit
						d9a34fb184
					
				
							
								
								
									
										97
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										97
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							@ -8,7 +8,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
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;
 | 
				
			||||||
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
 | 
					    var desc = Object.getOwnPropertyDescriptor(m, k);
 | 
				
			||||||
 | 
					    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
 | 
				
			||||||
 | 
					      desc = { enumerable: true, get: function() { return m[k]; } };
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    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];
 | 
				
			||||||
@ -21,7 +25,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
 | 
				
			|||||||
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.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;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@ -152,7 +156,11 @@ function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
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;
 | 
				
			||||||
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
 | 
					    var desc = Object.getOwnPropertyDescriptor(m, k);
 | 
				
			||||||
 | 
					    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
 | 
				
			||||||
 | 
					      desc = { enumerable: true, get: function() { return m[k]; } };
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    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];
 | 
				
			||||||
@ -165,7 +173,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
 | 
				
			|||||||
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.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;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@ -181,6 +189,7 @@ 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.DotnetVersionResolver = void 0;
 | 
				
			||||||
// Load tempDirectory before it gets wiped by tool-cache
 | 
					// Load tempDirectory before it gets wiped by tool-cache
 | 
				
			||||||
@ -191,6 +200,7 @@ const hc = __importStar(__nccwpck_require__(6255));
 | 
				
			|||||||
const fs_1 = __nccwpck_require__(7147);
 | 
					const fs_1 = __nccwpck_require__(7147);
 | 
				
			||||||
const promises_1 = __nccwpck_require__(3292);
 | 
					const promises_1 = __nccwpck_require__(3292);
 | 
				
			||||||
const path_1 = __importDefault(__nccwpck_require__(1017));
 | 
					const path_1 = __importDefault(__nccwpck_require__(1017));
 | 
				
			||||||
 | 
					const os_1 = __importDefault(__nccwpck_require__(2037));
 | 
				
			||||||
const semver_1 = __importDefault(__nccwpck_require__(5911));
 | 
					const semver_1 = __importDefault(__nccwpck_require__(5911));
 | 
				
			||||||
const utils_1 = __nccwpck_require__(918);
 | 
					const utils_1 = __nccwpck_require__(918);
 | 
				
			||||||
class DotnetVersionResolver {
 | 
					class DotnetVersionResolver {
 | 
				
			||||||
@ -269,27 +279,22 @@ class DotnetCoreInstaller {
 | 
				
			|||||||
        this.version = version;
 | 
					        this.version = version;
 | 
				
			||||||
        this.quality = quality;
 | 
					        this.quality = quality;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    static convertInstallPathToAbsolute(installDir) {
 | 
				
			||||||
 | 
					        let transformedPath;
 | 
				
			||||||
 | 
					        if (path_1.default.isAbsolute(installDir)) {
 | 
				
			||||||
 | 
					            transformedPath = installDir;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else {
 | 
				
			||||||
 | 
					            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);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    static addToPath() {
 | 
					    static addToPath() {
 | 
				
			||||||
        if (process.env['DOTNET_INSTALL_DIR']) {
 | 
					 | 
				
			||||||
        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']);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
            if (utils_1.IS_WINDOWS) {
 | 
					 | 
				
			||||||
                core.addPath(DotnetCoreInstaller.installationDirectoryWindows);
 | 
					 | 
				
			||||||
                core.exportVariable('DOTNET_ROOT', DotnetCoreInstaller.installationDirectoryWindows);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else if (utils_1.IS_LINUX) {
 | 
					 | 
				
			||||||
                core.addPath(DotnetCoreInstaller.installationDirectoryLinux);
 | 
					 | 
				
			||||||
                core.exportVariable('DOTNET_ROOT', DotnetCoreInstaller.installationDirectoryLinux);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else {
 | 
					 | 
				
			||||||
                // This is the default set in install-dotnet.sh
 | 
					 | 
				
			||||||
                core.addPath(DotnetCoreInstaller.installationDirectoryMac);
 | 
					 | 
				
			||||||
                core.exportVariable('DOTNET_ROOT', DotnetCoreInstaller.installationDirectoryMac);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    setQuality(dotnetVersion, scriptArguments) {
 | 
					    setQuality(dotnetVersion, scriptArguments) {
 | 
				
			||||||
        const option = utils_1.IS_WINDOWS ? '-Quality' : '--quality';
 | 
					        const option = utils_1.IS_WINDOWS ? '-Quality' : '--quality';
 | 
				
			||||||
        if (dotnetVersion.qualityFlag) {
 | 
					        if (dotnetVersion.qualityFlag) {
 | 
				
			||||||
@ -333,16 +338,12 @@ class DotnetCoreInstaller {
 | 
				
			|||||||
                if (process.env['no_proxy'] != null) {
 | 
					                if (process.env['no_proxy'] != null) {
 | 
				
			||||||
                    scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`);
 | 
					                    scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                if (!process.env['DOTNET_INSTALL_DIR']) {
 | 
					 | 
				
			||||||
                    process.env['DOTNET_INSTALL_DIR'] =
 | 
					 | 
				
			||||||
                        DotnetCoreInstaller.installationDirectoryWindows;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                scriptPath =
 | 
					                scriptPath =
 | 
				
			||||||
                    (yield io.which('pwsh', false)) || (yield io.which('powershell', true));
 | 
					                    (yield io.which('pwsh', false)) || (yield io.which('powershell', true));
 | 
				
			||||||
                scriptArguments = windowsDefaultOptions.concat(scriptArguments);
 | 
					                scriptArguments = windowsDefaultOptions.concat(scriptArguments);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else {
 | 
					            else {
 | 
				
			||||||
                fs_1.chmodSync(escapedScript, '777');
 | 
					                (0, fs_1.chmodSync)(escapedScript, '777');
 | 
				
			||||||
                scriptPath = yield io.which(escapedScript, true);
 | 
					                scriptPath = yield io.which(escapedScript, true);
 | 
				
			||||||
                scriptArguments = [];
 | 
					                scriptArguments = [];
 | 
				
			||||||
                if (dotnetVersion.type) {
 | 
					                if (dotnetVersion.type) {
 | 
				
			||||||
@ -351,11 +352,6 @@ class DotnetCoreInstaller {
 | 
				
			|||||||
                if (this.quality) {
 | 
					                if (this.quality) {
 | 
				
			||||||
                    this.setQuality(dotnetVersion, scriptArguments);
 | 
					                    this.setQuality(dotnetVersion, scriptArguments);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                if (!process.env['DOTNET_INSTALL_DIR']) {
 | 
					 | 
				
			||||||
                    process.env['DOTNET_INSTALL_DIR'] = utils_1.IS_LINUX
 | 
					 | 
				
			||||||
                        ? DotnetCoreInstaller.installationDirectoryLinux
 | 
					 | 
				
			||||||
                        : DotnetCoreInstaller.installationDirectoryMac;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
 | 
					            // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
 | 
				
			||||||
            const getExecOutputOptions = {
 | 
					            const getExecOutputOptions = {
 | 
				
			||||||
@ -366,12 +362,13 @@ class DotnetCoreInstaller {
 | 
				
			|||||||
            if (exitCode) {
 | 
					            if (exitCode) {
 | 
				
			||||||
                throw new Error(`Failed to install dotnet ${exitCode}. ${stdout}`);
 | 
					                throw new Error(`Failed to install dotnet ${exitCode}. ${stdout}`);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            return this.outputDotnetVersion(dotnetVersion.value, process.env['DOTNET_INSTALL_DIR']);
 | 
					            return this.outputDotnetVersion(dotnetVersion.value);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    outputDotnetVersion(version, installationPath) {
 | 
					    outputDotnetVersion(version) {
 | 
				
			||||||
        return __awaiter(this, void 0, void 0, function* () {
 | 
					        return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
            let versionsOnRunner = yield promises_1.readdir(path_1.default.join(installationPath.replace(/'/g, ''), 'sdk'));
 | 
					            const installationPath = process.env['DOTNET_INSTALL_DIR'];
 | 
				
			||||||
 | 
					            let versionsOnRunner = yield (0, promises_1.readdir)(path_1.default.join(installationPath.replace(/'/g, ''), 'sdk'));
 | 
				
			||||||
            let installedVersion = semver_1.default.maxSatisfying(versionsOnRunner, version, {
 | 
					            let installedVersion = semver_1.default.maxSatisfying(versionsOnRunner, version, {
 | 
				
			||||||
                includePrerelease: true
 | 
					                includePrerelease: true
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
@ -380,9 +377,27 @@ class DotnetCoreInstaller {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
exports.DotnetCoreInstaller = DotnetCoreInstaller;
 | 
					exports.DotnetCoreInstaller = DotnetCoreInstaller;
 | 
				
			||||||
DotnetCoreInstaller.installationDirectoryWindows = path_1.default.join(process.env['PROGRAMFILES'] + '', 'dotnet');
 | 
					_a = DotnetCoreInstaller;
 | 
				
			||||||
DotnetCoreInstaller.installationDirectoryLinux = '/usr/share/dotnet';
 | 
					(() => {
 | 
				
			||||||
DotnetCoreInstaller.installationDirectoryMac = path_1.default.join(process.env['HOME'] + '', '.dotnet');
 | 
					    const installationDirectoryWindows = path_1.default.join(process.env['PROGRAMFILES'] + '', 'dotnet');
 | 
				
			||||||
 | 
					    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;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					})();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/***/ }),
 | 
					/***/ }),
 | 
				
			||||||
@ -394,7 +409,11 @@ DotnetCoreInstaller.installationDirectoryMac = path_1.default.join(process.env['
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
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;
 | 
				
			||||||
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
 | 
					    var desc = Object.getOwnPropertyDescriptor(m, k);
 | 
				
			||||||
 | 
					    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
 | 
				
			||||||
 | 
					      desc = { enumerable: true, get: function() { return m[k]; } };
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    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];
 | 
				
			||||||
@ -407,7 +426,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
 | 
				
			|||||||
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.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;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -6,6 +6,7 @@ import * as hc from '@actions/http-client';
 | 
				
			|||||||
import {chmodSync} from 'fs';
 | 
					import {chmodSync} from 'fs';
 | 
				
			||||||
import {readdir} from 'fs/promises';
 | 
					import {readdir} from 'fs/promises';
 | 
				
			||||||
import path from 'path';
 | 
					import path from 'path';
 | 
				
			||||||
 | 
					import os from 'os';
 | 
				
			||||||
import semver from 'semver';
 | 
					import semver from 'semver';
 | 
				
			||||||
import {IS_LINUX, IS_WINDOWS} from './utils';
 | 
					import {IS_LINUX, IS_WINDOWS} from './utils';
 | 
				
			||||||
import {QualityOptions} from './setup-dotnet';
 | 
					import {QualityOptions} from './setup-dotnet';
 | 
				
			||||||
@ -112,40 +113,29 @@ export class DotnetVersionResolver {
 | 
				
			|||||||
export class DotnetCoreInstaller {
 | 
					export class DotnetCoreInstaller {
 | 
				
			||||||
  private version: string;
 | 
					  private version: string;
 | 
				
			||||||
  private quality: QualityOptions;
 | 
					  private quality: QualityOptions;
 | 
				
			||||||
  private static readonly installationDirectoryWindows = path.join(
 | 
					
 | 
				
			||||||
 | 
					  static {
 | 
				
			||||||
 | 
					    const installationDirectoryWindows = path.join(
 | 
				
			||||||
      process.env['PROGRAMFILES'] + '',
 | 
					      process.env['PROGRAMFILES'] + '',
 | 
				
			||||||
      'dotnet'
 | 
					      'dotnet'
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
  private static readonly installationDirectoryLinux = '/usr/share/dotnet';
 | 
					    const installationDirectoryLinux = '/usr/share/dotnet';
 | 
				
			||||||
  private static readonly installationDirectoryMac = path.join(
 | 
					    const installationDirectoryMac = path.join(
 | 
				
			||||||
      process.env['HOME'] + '',
 | 
					      process.env['HOME'] + '',
 | 
				
			||||||
      '.dotnet'
 | 
					      '.dotnet'
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					    const dotnetInstallDir: string | undefined =
 | 
				
			||||||
  static addToPath() {
 | 
					      process.env['DOTNET_INSTALL_DIR'];
 | 
				
			||||||
    if (process.env['DOTNET_INSTALL_DIR']) {
 | 
					    if (dotnetInstallDir) {
 | 
				
			||||||
      core.addPath(process.env['DOTNET_INSTALL_DIR']);
 | 
					      process.env['DOTNET_INSTALL_DIR'] =
 | 
				
			||||||
      core.exportVariable('DOTNET_ROOT', process.env['DOTNET_INSTALL_DIR']);
 | 
					        this.convertInstallPathToAbsolute(dotnetInstallDir);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      if (IS_WINDOWS) {
 | 
					      if (IS_WINDOWS) {
 | 
				
			||||||
        core.addPath(DotnetCoreInstaller.installationDirectoryWindows);
 | 
					        process.env['DOTNET_INSTALL_DIR'] = installationDirectoryWindows;
 | 
				
			||||||
        core.exportVariable(
 | 
					 | 
				
			||||||
          'DOTNET_ROOT',
 | 
					 | 
				
			||||||
          DotnetCoreInstaller.installationDirectoryWindows
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
      } else if (IS_LINUX) {
 | 
					 | 
				
			||||||
        core.addPath(DotnetCoreInstaller.installationDirectoryLinux);
 | 
					 | 
				
			||||||
        core.exportVariable(
 | 
					 | 
				
			||||||
          'DOTNET_ROOT',
 | 
					 | 
				
			||||||
          DotnetCoreInstaller.installationDirectoryLinux
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        // This is the default set in install-dotnet.sh
 | 
					        process.env['DOTNET_INSTALL_DIR'] = IS_LINUX
 | 
				
			||||||
        core.addPath(DotnetCoreInstaller.installationDirectoryMac);
 | 
					          ? installationDirectoryLinux
 | 
				
			||||||
        core.exportVariable(
 | 
					          : installationDirectoryMac;
 | 
				
			||||||
          'DOTNET_ROOT',
 | 
					 | 
				
			||||||
          DotnetCoreInstaller.installationDirectoryMac
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -155,6 +145,23 @@ export class DotnetCoreInstaller {
 | 
				
			|||||||
    this.quality = quality;
 | 
					    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(
 | 
					  private setQuality(
 | 
				
			||||||
    dotnetVersion: DotnetVersion,
 | 
					    dotnetVersion: DotnetVersion,
 | 
				
			||||||
    scriptArguments: string[]
 | 
					    scriptArguments: string[]
 | 
				
			||||||
@ -208,11 +215,6 @@ export class DotnetCoreInstaller {
 | 
				
			|||||||
        scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`);
 | 
					        scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (!process.env['DOTNET_INSTALL_DIR']) {
 | 
					 | 
				
			||||||
        process.env['DOTNET_INSTALL_DIR'] =
 | 
					 | 
				
			||||||
          DotnetCoreInstaller.installationDirectoryWindows;
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      scriptPath =
 | 
					      scriptPath =
 | 
				
			||||||
        (await io.which('pwsh', false)) || (await io.which('powershell', true));
 | 
					        (await io.which('pwsh', false)) || (await io.which('powershell', true));
 | 
				
			||||||
      scriptArguments = windowsDefaultOptions.concat(scriptArguments);
 | 
					      scriptArguments = windowsDefaultOptions.concat(scriptArguments);
 | 
				
			||||||
@ -228,12 +230,6 @@ export class DotnetCoreInstaller {
 | 
				
			|||||||
      if (this.quality) {
 | 
					      if (this.quality) {
 | 
				
			||||||
        this.setQuality(dotnetVersion, scriptArguments);
 | 
					        this.setQuality(dotnetVersion, scriptArguments);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					 | 
				
			||||||
      if (!process.env['DOTNET_INSTALL_DIR']) {
 | 
					 | 
				
			||||||
        process.env['DOTNET_INSTALL_DIR'] = IS_LINUX
 | 
					 | 
				
			||||||
          ? DotnetCoreInstaller.installationDirectoryLinux
 | 
					 | 
				
			||||||
          : DotnetCoreInstaller.installationDirectoryMac;
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
 | 
					    // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
 | 
				
			||||||
    const getExecOutputOptions = {
 | 
					    const getExecOutputOptions = {
 | 
				
			||||||
@ -249,16 +245,11 @@ export class DotnetCoreInstaller {
 | 
				
			|||||||
      throw new Error(`Failed to install dotnet ${exitCode}. ${stdout}`);
 | 
					      throw new Error(`Failed to install dotnet ${exitCode}. ${stdout}`);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return this.outputDotnetVersion(
 | 
					    return this.outputDotnetVersion(dotnetVersion.value);
 | 
				
			||||||
      dotnetVersion.value,
 | 
					 | 
				
			||||||
      process.env['DOTNET_INSTALL_DIR']
 | 
					 | 
				
			||||||
    );
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private async outputDotnetVersion(
 | 
					  private async outputDotnetVersion(version): Promise<string> {
 | 
				
			||||||
    version,
 | 
					    const installationPath = process.env['DOTNET_INSTALL_DIR']!;
 | 
				
			||||||
    installationPath
 | 
					 | 
				
			||||||
  ): Promise<string> {
 | 
					 | 
				
			||||||
    let versionsOnRunner: string[] = await readdir(
 | 
					    let versionsOnRunner: string[] = await readdir(
 | 
				
			||||||
      path.join(installationPath.replace(/'/g, ''), 'sdk')
 | 
					      path.join(installationPath.replace(/'/g, ''), 'sdk')
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user