Skip to content

Commit e968ad8

Browse files
committed
change install dir
1 parent 2216f56 commit e968ad8

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

dist/setup/index.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72836,7 +72836,7 @@ const core = __importStar(__nccwpck_require__(2186));
7283672836
const exec = __importStar(__nccwpck_require__(1514));
7283772837
const io = __importStar(__nccwpck_require__(7436));
7283872838
const hc = __importStar(__nccwpck_require__(6255));
72839-
const fs_1 = __nccwpck_require__(7147);
72839+
const fs_1 = __importStar(__nccwpck_require__(7147));
7284072840
const path_1 = __importDefault(__nccwpck_require__(1017));
7284172841
const os_1 = __importDefault(__nccwpck_require__(2037));
7284272842
const semver_1 = __importDefault(__nccwpck_require__(5911));
@@ -73008,6 +73008,16 @@ class DotnetInstallScript {
7300873008
}
7300973009
}
7301073010
exports.DotnetInstallScript = DotnetInstallScript;
73011+
// Workaround for slow installation on Windows with network attached C: drive
73012+
// see https://github.com/actions/setup-dotnet/issues/260
73013+
const fixWindowsInstallDir = (installDir) => {
73014+
if (!(0, utils_1.isSelfHosted)() && fs_1.default.existsSync('d:\\')) {
73015+
return installDir.replace(/^[cC]:\\/, 'd:\\');
73016+
}
73017+
else {
73018+
return installDir;
73019+
}
73020+
};
7301173021
class DotnetInstallDir {
7301273022
static convertInstallPathToAbsolute(installDir) {
7301373023
if (path_1.default.isAbsolute(installDir))
@@ -73029,7 +73039,7 @@ exports.DotnetInstallDir = DotnetInstallDir;
7302973039
DotnetInstallDir.default = {
7303073040
linux: '/usr/share/dotnet',
7303173041
mac: path_1.default.join(process.env['HOME'] + '', '.dotnet'),
73032-
windows: path_1.default.join(process.env['PROGRAMFILES'] + '', 'dotnet')
73042+
windows: fixWindowsInstallDir(path_1.default.join(process.env['PROGRAMFILES'] + '', 'dotnet'))
7303373043
};
7303473044
DotnetInstallDir.dirPath = process.env['DOTNET_INSTALL_DIR']
7303573045
? DotnetInstallDir.convertInstallPathToAbsolute(process.env['DOTNET_INSTALL_DIR'])
@@ -73272,7 +73282,7 @@ run();
7327273282
"use strict";
7327373283

7327473284
Object.defineProperty(exports, "__esModule", ({ value: true }));
73275-
exports.PLATFORM = exports.IS_WINDOWS = void 0;
73285+
exports.isSelfHosted = exports.PLATFORM = exports.IS_WINDOWS = void 0;
7327673286
exports.IS_WINDOWS = process.platform === 'win32';
7327773287
exports.PLATFORM = (() => {
7327873288
if (process.platform === 'win32')
@@ -73281,6 +73291,10 @@ exports.PLATFORM = (() => {
7328173291
return 'linux';
7328273292
return 'mac';
7328373293
})();
73294+
const isSelfHosted = () => process.env['AGENT_ISSELFHOSTED'] === '1' ||
73295+
(process.env['AGENT_ISSELFHOSTED'] === undefined &&
73296+
process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted');
73297+
exports.isSelfHosted = isSelfHosted;
7328473298

7328573299

7328673300
/***/ }),

src/installer.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import * as core from '@actions/core';
33
import * as exec from '@actions/exec';
44
import * as io from '@actions/io';
55
import * as hc from '@actions/http-client';
6-
import {chmodSync} from 'fs';
6+
import fs, {chmodSync} from 'fs';
77
import path from 'path';
88
import os from 'os';
99
import semver from 'semver';
10-
import {IS_WINDOWS, PLATFORM} from './utils';
10+
import {IS_WINDOWS, isSelfHosted, PLATFORM} from './utils';
1111
import {QualityOptions} from './setup-dotnet';
1212

1313
export interface DotnetVersion {
@@ -215,11 +215,23 @@ export class DotnetInstallScript {
215215
}
216216
}
217217

218+
// Workaround for slow installation on Windows with network attached C: drive
219+
// see https://github.com/actions/setup-dotnet/issues/260
220+
const fixWindowsInstallDir = (installDir: string): string => {
221+
if (!isSelfHosted() && fs.existsSync('d:\\')) {
222+
return installDir.replace(/^[cC]:\\/, 'd:\\');
223+
} else {
224+
return installDir;
225+
}
226+
};
227+
218228
export abstract class DotnetInstallDir {
219229
private static readonly default = {
220230
linux: '/usr/share/dotnet',
221231
mac: path.join(process.env['HOME'] + '', '.dotnet'),
222-
windows: path.join(process.env['PROGRAMFILES'] + '', 'dotnet')
232+
windows: fixWindowsInstallDir(
233+
path.join(process.env['PROGRAMFILES'] + '', 'dotnet')
234+
)
223235
};
224236

225237
public static readonly dirPath = process.env['DOTNET_INSTALL_DIR']

src/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ export const PLATFORM = ((): 'windows' | 'linux' | 'mac' => {
44
if (process.platform === 'linux') return 'linux';
55
return 'mac';
66
})();
7+
export const isSelfHosted = (): boolean =>
8+
process.env['AGENT_ISSELFHOSTED'] === '1' ||
9+
(process.env['AGENT_ISSELFHOSTED'] === undefined &&
10+
process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted');

0 commit comments

Comments
 (0)