Skip to content

Commit

Permalink
change install dir
Browse files Browse the repository at this point in the history
  • Loading branch information
dsame committed Nov 9, 2023
1 parent 2216f56 commit e968ad8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
20 changes: 17 additions & 3 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72836,7 +72836,7 @@ const core = __importStar(__nccwpck_require__(2186));
const exec = __importStar(__nccwpck_require__(1514));
const io = __importStar(__nccwpck_require__(7436));
const hc = __importStar(__nccwpck_require__(6255));
const fs_1 = __nccwpck_require__(7147);
const fs_1 = __importStar(__nccwpck_require__(7147));
const path_1 = __importDefault(__nccwpck_require__(1017));
const os_1 = __importDefault(__nccwpck_require__(2037));
const semver_1 = __importDefault(__nccwpck_require__(5911));
Expand Down Expand Up @@ -73008,6 +73008,16 @@ class DotnetInstallScript {
}
}
exports.DotnetInstallScript = DotnetInstallScript;
// Workaround for slow installation on Windows with network attached C: drive
// see https://github.com/actions/setup-dotnet/issues/260
const fixWindowsInstallDir = (installDir) => {
if (!(0, utils_1.isSelfHosted)() && fs_1.default.existsSync('d:\\')) {
return installDir.replace(/^[cC]:\\/, 'd:\\');
}
else {
return installDir;
}
};
class DotnetInstallDir {
static convertInstallPathToAbsolute(installDir) {
if (path_1.default.isAbsolute(installDir))
Expand All @@ -73029,7 +73039,7 @@ exports.DotnetInstallDir = DotnetInstallDir;
DotnetInstallDir.default = {
linux: '/usr/share/dotnet',
mac: path_1.default.join(process.env['HOME'] + '', '.dotnet'),
windows: path_1.default.join(process.env['PROGRAMFILES'] + '', 'dotnet')
windows: fixWindowsInstallDir(path_1.default.join(process.env['PROGRAMFILES'] + '', 'dotnet'))
};
DotnetInstallDir.dirPath = process.env['DOTNET_INSTALL_DIR']
? DotnetInstallDir.convertInstallPathToAbsolute(process.env['DOTNET_INSTALL_DIR'])
Expand Down Expand Up @@ -73272,7 +73282,7 @@ run();
"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.PLATFORM = exports.IS_WINDOWS = void 0;
exports.isSelfHosted = exports.PLATFORM = exports.IS_WINDOWS = void 0;
exports.IS_WINDOWS = process.platform === 'win32';
exports.PLATFORM = (() => {
if (process.platform === 'win32')
Expand All @@ -73281,6 +73291,10 @@ exports.PLATFORM = (() => {
return 'linux';
return 'mac';
})();
const isSelfHosted = () => process.env['AGENT_ISSELFHOSTED'] === '1' ||
(process.env['AGENT_ISSELFHOSTED'] === undefined &&
process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted');
exports.isSelfHosted = isSelfHosted;


/***/ }),
Expand Down
18 changes: 15 additions & 3 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as io from '@actions/io';
import * as hc from '@actions/http-client';
import {chmodSync} from 'fs';
import fs, {chmodSync} from 'fs';
import path from 'path';
import os from 'os';
import semver from 'semver';
import {IS_WINDOWS, PLATFORM} from './utils';
import {IS_WINDOWS, isSelfHosted, PLATFORM} from './utils';
import {QualityOptions} from './setup-dotnet';

export interface DotnetVersion {
Expand Down Expand Up @@ -215,11 +215,23 @@ export class DotnetInstallScript {
}
}

// Workaround for slow installation on Windows with network attached C: drive
// see https://github.com/actions/setup-dotnet/issues/260
const fixWindowsInstallDir = (installDir: string): string => {
if (!isSelfHosted() && fs.existsSync('d:\\')) {
return installDir.replace(/^[cC]:\\/, 'd:\\');
} else {
return installDir;
}
};

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')
windows: fixWindowsInstallDir(
path.join(process.env['PROGRAMFILES'] + '', 'dotnet')
)
};

public static readonly dirPath = process.env['DOTNET_INSTALL_DIR']
Expand Down
4 changes: 4 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ export const PLATFORM = ((): 'windows' | 'linux' | 'mac' => {
if (process.platform === 'linux') return 'linux';
return 'mac';
})();
export const isSelfHosted = (): boolean =>
process.env['AGENT_ISSELFHOSTED'] === '1' ||
(process.env['AGENT_ISSELFHOSTED'] === undefined &&
process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted');

0 comments on commit e968ad8

Please sign in to comment.