Compare commits
5
Commits
349aa191ae
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ec5c6b286 | ||
|
|
62573f4b60 | ||
|
|
67290a9d23 | ||
|
|
0072421cf6 | ||
|
|
9ead3175a9 |
No files matched your search
@@ -747,7 +747,7 @@ jobs:
|
|||||||
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
- name: Clear toolcache
|
- name: Clear toolcache
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
||||||
|
|||||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: brace-expansion
|
name: brace-expansion
|
||||||
version: 1.1.18
|
version: 1.1.21
|
||||||
type: npm
|
type: npm
|
||||||
summary: Brace expansion as known from sh/bash
|
summary: Brace expansion as known from sh/bash
|
||||||
homepage: https://github.com/juliangruber/brace-expansion
|
homepage: https://github.com/juliangruber/brace-expansion
|
||||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: brace-expansion
|
name: brace-expansion
|
||||||
version: 5.0.9
|
version: 5.0.12
|
||||||
type: npm
|
type: npm
|
||||||
summary: Brace expansion as known from sh/bash
|
summary: Brace expansion as known from sh/bash
|
||||||
homepage:
|
homepage:
|
||||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: undici
|
name: undici
|
||||||
version: 6.28.0
|
version: 6.29.1
|
||||||
type: npm
|
type: npm
|
||||||
summary: An HTTP/1.1 client, written from scratch for Node.js
|
summary: An HTTP/1.1 client, written from scratch for Node.js
|
||||||
homepage: https://undici.nodejs.org
|
homepage: https://undici.nodejs.org
|
||||||
|
|||||||
@@ -452,7 +452,13 @@ You can also set `DOTNET_INSTALL_DIR` to a value based on runtime variables, suc
|
|||||||
- name: Set DOTNET_INSTALL_DIR
|
- name: Set DOTNET_INSTALL_DIR
|
||||||
run: echo "DOTNET_INSTALL_DIR=$HOME/.dotnet" >> $GITHUB_ENV
|
run: echo "DOTNET_INSTALL_DIR=$HOME/.dotnet" >> $GITHUB_ENV
|
||||||
```
|
```
|
||||||
> **Note**: On some self-hosted or large Linux runners, installing .NET under the default `/usr/share/dotnet` location may fail due to insufficient permissions. To ensure successful installation, set `DOTNET_INSTALL_DIR` to a user-writable path.
|
> **Note**: On some self-hosted, larger or containerized runners the default location is not writable by the current user, and the installation fails with a permission error. The action resolves the install directory in this order:
|
||||||
|
>
|
||||||
|
> 1. `DOTNET_INSTALL_DIR`, when set. It is always honored and never probed.
|
||||||
|
> 2. The default location for the runner OS, when it is writable.
|
||||||
|
> 3. `.dotnet` in the current user's home directory, for example `/home/runner/.dotnet` or `C:\Users\runneradmin\.dotnet`.
|
||||||
|
>
|
||||||
|
> Runners that can write to the default location are unaffected. When the fallback is used, `DOTNET_ROOT` and `PATH` point at the home directory, so .NET preinstalled under the system location is no longer picked up. Set `DOTNET_INSTALL_DIR` explicitly to pin the location. If no writable location is found, the action warns and keeps the default, so the installation is likely to fail.
|
||||||
|
|
||||||
## Recommended permissions
|
## Recommended permissions
|
||||||
|
|
||||||
|
|||||||
+266
-10
@@ -11,6 +11,7 @@ import {
|
|||||||
import each from 'jest-each';
|
import each from 'jest-each';
|
||||||
import semver from 'semver';
|
import semver from 'semver';
|
||||||
import fspromises from 'fs/promises';
|
import fspromises from 'fs/promises';
|
||||||
|
import type {Stats} from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
@@ -35,26 +36,47 @@ jest.unstable_mockModule('@actions/io', () => ({
|
|||||||
jest.unstable_mockModule('fs', () => {
|
jest.unstable_mockModule('fs', () => {
|
||||||
const actual = jest.requireActual('fs') as typeof import('fs');
|
const actual = jest.requireActual('fs') as typeof import('fs');
|
||||||
const chmodSync = jest.fn();
|
const chmodSync = jest.fn();
|
||||||
|
const lstatSync = jest.fn(actual.lstatSync);
|
||||||
|
const mkdtempSync = jest.fn(actual.mkdtempSync);
|
||||||
|
const rmSync = jest.fn(actual.rmSync);
|
||||||
const readdirSync = jest.fn();
|
const readdirSync = jest.fn();
|
||||||
const existsSync = jest.fn(() => true);
|
const existsSync = jest.fn(() => true);
|
||||||
const statSync = jest.fn(() => ({isFile: () => true}));
|
const statSync = jest.fn(() => ({isFile: () => true}));
|
||||||
const accessSync = jest.fn();
|
const accessSync = jest.fn();
|
||||||
return {
|
const mocked = {
|
||||||
...actual,
|
...actual,
|
||||||
chmodSync,
|
chmodSync,
|
||||||
|
lstatSync,
|
||||||
|
mkdtempSync,
|
||||||
|
rmSync,
|
||||||
readdirSync,
|
readdirSync,
|
||||||
existsSync,
|
existsSync,
|
||||||
statSync,
|
statSync,
|
||||||
accessSync,
|
accessSync
|
||||||
default: {
|
|
||||||
...actual,
|
|
||||||
chmodSync,
|
|
||||||
readdirSync,
|
|
||||||
existsSync,
|
|
||||||
statSync,
|
|
||||||
accessSync
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
return {
|
||||||
|
...mocked,
|
||||||
|
default: mocked
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
jest.unstable_mockModule('os', () => {
|
||||||
|
const actual = jest.requireActual('os') as typeof import('os');
|
||||||
|
// os.homedir() reads the real environment, not jest's process.env.
|
||||||
|
const homedir = jest.fn(actual.homedir);
|
||||||
|
// Resolved per call, so spies placed on the real module still take effect.
|
||||||
|
const arch = () => actual.arch();
|
||||||
|
return {...actual, homedir, arch, default: {...actual, homedir, arch}};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Allows tests to re-import the installer as if running on another OS.
|
||||||
|
let platformOverride: 'windows' | 'linux' | 'mac' | undefined;
|
||||||
|
jest.unstable_mockModule('../src/utils.js', () => {
|
||||||
|
const actual = jest.requireActual(
|
||||||
|
'../src/utils.js'
|
||||||
|
) as typeof import('../src/utils.js');
|
||||||
|
const platform = platformOverride ?? actual.PLATFORM;
|
||||||
|
return {...actual, PLATFORM: platform, IS_WINDOWS: platform === 'windows'};
|
||||||
});
|
});
|
||||||
|
|
||||||
const exec = await import('@actions/exec');
|
const exec = await import('@actions/exec');
|
||||||
@@ -1364,6 +1386,240 @@ describe('installer tests', () => {
|
|||||||
expect(path).toContain(process.env['DOTNET_INSTALL_DIR']);
|
expect(path).toContain(process.env['DOTNET_INSTALL_DIR']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('install directory fallback tests', () => {
|
||||||
|
// Mock factories re-run on resetModules, so the installer sees new
|
||||||
|
// instances; configure those, not the ones captured at file load.
|
||||||
|
const importInstallerFor = async (
|
||||||
|
platform: 'windows' | 'linux' | 'mac',
|
||||||
|
isWritable: (dir: string) => boolean
|
||||||
|
) => {
|
||||||
|
platformOverride = platform;
|
||||||
|
jest.resetModules();
|
||||||
|
|
||||||
|
const freshFs = await import('fs');
|
||||||
|
(freshFs.lstatSync as jest.Mock).mockReturnValue({} as Stats);
|
||||||
|
(freshFs.mkdtempSync as jest.Mock).mockImplementation(
|
||||||
|
(...args: unknown[]) => {
|
||||||
|
const prefix = String(args[0]);
|
||||||
|
if (!isWritable(path.dirname(prefix))) {
|
||||||
|
throw Object.assign(new Error('permission denied'), {
|
||||||
|
code: 'EACCES'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return `${prefix}abc123`;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
(freshFs.rmSync as jest.Mock).mockImplementation(() => {});
|
||||||
|
|
||||||
|
const freshCore = await import('@actions/core');
|
||||||
|
const freshOs = await import('os');
|
||||||
|
const {DotnetInstallDir} = await import('../src/installer.js');
|
||||||
|
|
||||||
|
return {DotnetInstallDir, core: freshCore, fs: freshFs, os: freshOs};
|
||||||
|
};
|
||||||
|
|
||||||
|
const probedDirs = (freshFs: typeof import('fs')) =>
|
||||||
|
(freshFs.mkdtempSync as jest.Mock).mock.calls.map(call =>
|
||||||
|
path.dirname(String(call[0]))
|
||||||
|
);
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
delete process.env['DOTNET_INSTALL_DIR'];
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
platformOverride = undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should use the default location when it is writable`, async () => {
|
||||||
|
const {DotnetInstallDir} = await importInstallerFor(
|
||||||
|
'linux',
|
||||||
|
() => true
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(DotnetInstallDir.dirPath).toBe('/usr/share/dotnet');
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should fall back to the home directory when the default location is not writable`, async () => {
|
||||||
|
const fallbackPath = path.join(os.homedir(), '.dotnet');
|
||||||
|
const {DotnetInstallDir, core: freshCore} = await importInstallerFor(
|
||||||
|
'linux',
|
||||||
|
dir => dir === fallbackPath
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(DotnetInstallDir.dirPath).toBe(fallbackPath);
|
||||||
|
expect(freshCore.warning).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should reject a dangling symlink instead of probing its writable parent`, async () => {
|
||||||
|
// Resolved, because that is the form the probe receives on every platform.
|
||||||
|
const linkPath = path.resolve('/usr/share/dotnet');
|
||||||
|
const {DotnetInstallDir, fs: freshFs} = await importInstallerFor(
|
||||||
|
'linux',
|
||||||
|
() => true
|
||||||
|
);
|
||||||
|
// A dangling link exists for lstat, but nothing can be created under it.
|
||||||
|
(freshFs.mkdtempSync as jest.Mock).mockImplementation(
|
||||||
|
(...args: unknown[]) => {
|
||||||
|
if (path.dirname(String(args[0])) === linkPath) {
|
||||||
|
throw Object.assign(new Error('no such file or directory'), {
|
||||||
|
code: 'ENOENT'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return `${args[0]}abc123`;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(DotnetInstallDir.dirPath).toBe(
|
||||||
|
path.join(os.homedir(), '.dotnet')
|
||||||
|
);
|
||||||
|
const probed = probedDirs(freshFs);
|
||||||
|
expect(probed).toContain(linkPath);
|
||||||
|
expect(probed).not.toContain(path.dirname(linkPath));
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should probe the nearest existing parent when the directory is missing`, async () => {
|
||||||
|
const systemPath = path.resolve('/usr/share/dotnet');
|
||||||
|
const parentPath = path.dirname(systemPath);
|
||||||
|
const {DotnetInstallDir, fs: freshFs} = await importInstallerFor(
|
||||||
|
'linux',
|
||||||
|
() => true
|
||||||
|
);
|
||||||
|
// Only the parent exists, so the walk has to climb before probing.
|
||||||
|
(freshFs.lstatSync as jest.Mock).mockImplementation(
|
||||||
|
(...args: unknown[]) =>
|
||||||
|
path.resolve(String(args[0])) === parentPath
|
||||||
|
? ({} as Stats)
|
||||||
|
: undefined
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(DotnetInstallDir.dirPath).toBe('/usr/share/dotnet');
|
||||||
|
const probed = probedDirs(freshFs);
|
||||||
|
expect(probed).toContain(parentPath);
|
||||||
|
expect(probed).not.toContain(systemPath);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should give up at the filesystem root when no ancestor exists`, async () => {
|
||||||
|
const systemPath = path.resolve('/usr/share/dotnet');
|
||||||
|
const homePath = path.join(os.homedir(), '.dotnet');
|
||||||
|
const {DotnetInstallDir, fs: freshFs} = await importInstallerFor(
|
||||||
|
'linux',
|
||||||
|
() => true
|
||||||
|
);
|
||||||
|
// Nothing on the system path exists, all the way up to the root.
|
||||||
|
(freshFs.lstatSync as jest.Mock).mockImplementation(
|
||||||
|
(...args: unknown[]) =>
|
||||||
|
systemPath.startsWith(path.resolve(String(args[0])))
|
||||||
|
? undefined
|
||||||
|
: ({} as Stats)
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(DotnetInstallDir.dirPath).toBe(homePath);
|
||||||
|
// The walk hit the root and returned without ever probing.
|
||||||
|
expect(probedDirs(freshFs)).toEqual([homePath]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should not probe a relative default location`, async () => {
|
||||||
|
// An unset HOME makes the macOS default relative, e.g. 'undefined/.dotnet'.
|
||||||
|
delete process.env['HOME'];
|
||||||
|
const homePath = path.join(os.homedir(), '.dotnet');
|
||||||
|
const {DotnetInstallDir, fs: freshFs} = await importInstallerFor(
|
||||||
|
'mac',
|
||||||
|
() => true
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(DotnetInstallDir.dirPath).toBe(homePath);
|
||||||
|
expect(probedDirs(freshFs)).not.toContain(process.cwd());
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should not probe a relative default location on Windows`, async () => {
|
||||||
|
// An unset PROGRAMFILES makes the Windows default relative.
|
||||||
|
delete process.env['PROGRAMFILES'];
|
||||||
|
const homePath = path.join(os.homedir(), '.dotnet');
|
||||||
|
const {DotnetInstallDir, fs: freshFs} = await importInstallerFor(
|
||||||
|
'windows',
|
||||||
|
() => true
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(DotnetInstallDir.dirPath).toBe(homePath);
|
||||||
|
expect(probedDirs(freshFs)).not.toContain(process.cwd());
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should not treat the filesystem root as a home directory`, async () => {
|
||||||
|
const root = path.parse(process.cwd()).root;
|
||||||
|
const rootDotnet = path.join(root, '.dotnet');
|
||||||
|
// Only the root candidate is writable, so an unguarded run would pick it.
|
||||||
|
const {
|
||||||
|
DotnetInstallDir,
|
||||||
|
os: freshOs,
|
||||||
|
core: freshCore
|
||||||
|
} = await importInstallerFor('linux', dir => dir === rootDotnet);
|
||||||
|
(freshOs.homedir as jest.Mock).mockReturnValue(root);
|
||||||
|
|
||||||
|
expect(DotnetInstallDir.dirPath).toBe('/usr/share/dotnet');
|
||||||
|
expect(freshCore.warning).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should still report writable when the probe cannot be removed`, async () => {
|
||||||
|
const {DotnetInstallDir, fs: freshFs} = await importInstallerFor(
|
||||||
|
'linux',
|
||||||
|
() => true
|
||||||
|
);
|
||||||
|
(freshFs.rmSync as jest.Mock).mockImplementation(() => {
|
||||||
|
throw Object.assign(new Error('device or resource busy'), {
|
||||||
|
code: 'EBUSY'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(DotnetInstallDir.dirPath).toBe('/usr/share/dotnet');
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should keep the shared macOS location and warn when it is not writable`, async () => {
|
||||||
|
// The mac default derives from HOME, homeInstallPath() from os.homedir();
|
||||||
|
// aligning them is what makes both candidates the same path.
|
||||||
|
process.env['HOME'] = os.homedir();
|
||||||
|
const homePath = path.join(os.homedir(), '.dotnet');
|
||||||
|
const {
|
||||||
|
DotnetInstallDir,
|
||||||
|
fs: freshFs,
|
||||||
|
core: freshCore
|
||||||
|
} = await importInstallerFor('mac', () => false);
|
||||||
|
|
||||||
|
expect(DotnetInstallDir.dirPath).toBe(homePath);
|
||||||
|
// One candidate, so it is probed once rather than twice.
|
||||||
|
expect(probedDirs(freshFs)).toEqual([homePath]);
|
||||||
|
expect(freshCore.warning).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should prefer DOTNET_INSTALL_DIR env.var without probing`, async () => {
|
||||||
|
process.env['DOTNET_INSTALL_DIR'] = path.join(path.sep, 'custom');
|
||||||
|
const {DotnetInstallDir, fs: freshFs} = await importInstallerFor(
|
||||||
|
'linux',
|
||||||
|
() => false
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(DotnetInstallDir.dirPath).toBe(path.join(path.sep, 'custom'));
|
||||||
|
expect(freshFs.mkdtempSync as jest.Mock).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should resolve once, and not before the directory is needed`, async () => {
|
||||||
|
const {DotnetInstallDir, fs: freshFs} = await importInstallerFor(
|
||||||
|
'linux',
|
||||||
|
() => true
|
||||||
|
);
|
||||||
|
const probe = freshFs.mkdtempSync as jest.Mock;
|
||||||
|
|
||||||
|
expect(probe).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
void DotnetInstallDir.dirPath;
|
||||||
|
const afterFirstRead = probe.mock.calls.length;
|
||||||
|
void DotnetInstallDir.dirPath;
|
||||||
|
|
||||||
|
expect(afterFirstRead).toBeGreaterThan(0);
|
||||||
|
expect(probe.mock.calls.length).toBe(afterFirstRead);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('normalizeArch() tests', () => {
|
describe('normalizeArch() tests', () => {
|
||||||
|
|||||||
Vendored
+656
-230
File diff suppressed because it is too large.
Load diff
Vendored
+804
-260
File diff suppressed because it is too large.
Load diff
Generated
+26
-16
@@ -2888,9 +2888,9 @@
|
|||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0"
|
||||||
},
|
},
|
||||||
"node_modules/brace-expansion": {
|
"node_modules/brace-expansion": {
|
||||||
"version": "5.0.9",
|
"version": "5.0.12",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz",
|
||||||
"integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
|
"integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"balanced-match": "^4.0.2"
|
"balanced-match": "^4.0.2"
|
||||||
@@ -4035,9 +4035,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/glob/node_modules/brace-expansion": {
|
"node_modules/glob/node_modules/brace-expansion": {
|
||||||
"version": "2.1.4",
|
"version": "2.1.7",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.7.tgz",
|
||||||
"integrity": "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==",
|
"integrity": "sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -4087,13 +4087,13 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/handlebars": {
|
"node_modules/handlebars": {
|
||||||
"version": "4.7.9",
|
"version": "4.7.10",
|
||||||
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.9.tgz",
|
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.10.tgz",
|
||||||
"integrity": "sha512-4E71E0rpOaQuJR2A3xDZ+GM1HyWYv1clR58tC8emQNeQe3RH7MAzSbat+V0wG78LQBo6m6bzSG/L4pBuCsgnUQ==",
|
"integrity": "sha512-P5VJMVM7qgBn6vjXMw8WG9uVI+ncf2pi72j4de4yz5ZULLj2RGqLYaKOYGsgyrViQ0tePOVlN1tDCCXXtFqXKg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"minimist": "^1.2.5",
|
"minimist": "^1.2.8",
|
||||||
"neo-async": "^2.6.2",
|
"neo-async": "^2.6.2",
|
||||||
"source-map": "^0.6.1",
|
"source-map": "^0.6.1",
|
||||||
"wordwrap": "^1.0.0"
|
"wordwrap": "^1.0.0"
|
||||||
@@ -4108,6 +4108,16 @@
|
|||||||
"uglify-js": "^3.1.4"
|
"uglify-js": "^3.1.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/handlebars/node_modules/minimist": {
|
||||||
|
"version": "1.2.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
|
||||||
|
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/has-flag": {
|
"node_modules/has-flag": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||||
@@ -5246,9 +5256,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/minimatch/node_modules/brace-expansion": {
|
"node_modules/minimatch/node_modules/brace-expansion": {
|
||||||
"version": "1.1.18",
|
"version": "1.1.21",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz",
|
||||||
"integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==",
|
"integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"balanced-match": "^1.0.0",
|
"balanced-match": "^1.0.0",
|
||||||
@@ -6356,9 +6366,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici": {
|
"node_modules/undici": {
|
||||||
"version": "6.28.0",
|
"version": "6.29.1",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-6.28.0.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-6.29.1.tgz",
|
||||||
"integrity": "sha512-LIY910g9TI13YS95lrMFrs8Rm/u/irgHeTWoKCoteeJ04CUJ92eEfj0rVn+7VKMPBpUPiUoBKfhNyLI23EE/KA==",
|
"integrity": "sha512-EvRlUt/QqAEvXdQeRMYUfwOQsfzpDztykrG2owGEE/rBOBoYv9uF39ZzsNDh4lTFHhTr2XOZjKkYgueD12ZmGA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.17"
|
"node": ">=18.17"
|
||||||
|
|||||||
+96
-8
@@ -7,7 +7,10 @@ import {
|
|||||||
accessSync,
|
accessSync,
|
||||||
chmodSync,
|
chmodSync,
|
||||||
constants as fsConstants,
|
constants as fsConstants,
|
||||||
|
lstatSync,
|
||||||
|
mkdtempSync,
|
||||||
readdirSync,
|
readdirSync,
|
||||||
|
rmSync,
|
||||||
statSync
|
statSync
|
||||||
} from 'fs';
|
} from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
@@ -347,11 +350,97 @@ export abstract class DotnetInstallDir {
|
|||||||
windows: path.join(process.env['PROGRAMFILES'] + '', 'dotnet')
|
windows: path.join(process.env['PROGRAMFILES'] + '', 'dotnet')
|
||||||
};
|
};
|
||||||
|
|
||||||
public static readonly dirPath = process.env['DOTNET_INSTALL_DIR']
|
private static resolvedDirPath: string | undefined;
|
||||||
? DotnetInstallDir.convertInstallPathToAbsolute(
|
|
||||||
|
// Resolved on first use so a job that installs nothing never touches the disk.
|
||||||
|
public static get dirPath(): string {
|
||||||
|
DotnetInstallDir.resolvedDirPath ??= DotnetInstallDir.resolveDirPath();
|
||||||
|
return DotnetInstallDir.resolvedDirPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static resolveDirPath(): string {
|
||||||
|
if (process.env['DOTNET_INSTALL_DIR']) {
|
||||||
|
return DotnetInstallDir.convertInstallPathToAbsolute(
|
||||||
process.env['DOTNET_INSTALL_DIR']
|
process.env['DOTNET_INSTALL_DIR']
|
||||||
)
|
);
|
||||||
: DotnetInstallDir.default[PLATFORM];
|
}
|
||||||
|
|
||||||
|
const systemPath = DotnetInstallDir.default[PLATFORM];
|
||||||
|
const homePath = DotnetInstallDir.homeInstallPath();
|
||||||
|
|
||||||
|
// A relative default (unset HOME/PROGRAMFILES) would probe the cwd.
|
||||||
|
if (
|
||||||
|
path.isAbsolute(systemPath) &&
|
||||||
|
DotnetInstallDir.isWritableLocation(systemPath)
|
||||||
|
) {
|
||||||
|
return systemPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
// On macOS both candidates are the same path, already probed above.
|
||||||
|
const hasFallback = !!homePath && homePath !== systemPath;
|
||||||
|
|
||||||
|
if (hasFallback && DotnetInstallDir.isWritableLocation(homePath!)) {
|
||||||
|
core.warning(
|
||||||
|
`The default .NET install directory '${systemPath}' is not writable by the current user. Falling back to '${homePath}'; .NET preinstalled in the default location will no longer be used. Set the DOTNET_INSTALL_DIR environment variable to override this location.`
|
||||||
|
);
|
||||||
|
return homePath!;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not setFailed: the install may still succeed, so let it report the error.
|
||||||
|
core.warning(
|
||||||
|
hasFallback
|
||||||
|
? `Neither the default .NET install directory '${systemPath}' nor '${homePath}' is writable by the current user. Keeping '${systemPath}', but the installation is likely to fail. Set the DOTNET_INSTALL_DIR environment variable to a writable location.`
|
||||||
|
: `The default .NET install directory '${systemPath}' is not writable by the current user. Keeping it, but the installation is likely to fail. Set the DOTNET_INSTALL_DIR environment variable to a writable location.`
|
||||||
|
);
|
||||||
|
return systemPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static homeInstallPath(): string | undefined {
|
||||||
|
try {
|
||||||
|
const home = os.homedir();
|
||||||
|
// An empty HOME resolves against the cwd; a root HOME gives '/.dotnet'.
|
||||||
|
if (!path.isAbsolute(home) || home === path.parse(home).root) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return path.join(home, '.dotnet');
|
||||||
|
} catch {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Writability is tested by creating a directory. accessSync is not enough: it
|
||||||
|
// ignores Windows ACLs, so it reports success where the install would fail.
|
||||||
|
private static isWritableLocation(installDir: string): boolean {
|
||||||
|
let existingPath = path.resolve(installDir);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// lstat also matches a broken symlink. existsSync does not, and the walk
|
||||||
|
// would skip past it to a writable parent and wrongly report success.
|
||||||
|
while (!lstatSync(existingPath, {throwIfNoEntry: false})) {
|
||||||
|
const parentPath = path.dirname(existingPath);
|
||||||
|
if (parentPath === existingPath) return false;
|
||||||
|
existingPath = parentPath;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let probeDir: string | undefined;
|
||||||
|
try {
|
||||||
|
probeDir = mkdtempSync(path.join(existingPath, '.setup-dotnet-probe-'));
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
if (probeDir) {
|
||||||
|
try {
|
||||||
|
rmSync(probeDir, {recursive: true, force: true});
|
||||||
|
} catch {
|
||||||
|
// Throwing here would discard the result already returned above.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static convertInstallPathToAbsolute(installDir: string): string {
|
private static convertInstallPathToAbsolute(installDir: string): string {
|
||||||
if (path.isAbsolute(installDir)) return path.normalize(installDir);
|
if (path.isAbsolute(installDir)) return path.normalize(installDir);
|
||||||
@@ -410,10 +499,6 @@ function isExecutableFile(filePath: string): boolean {
|
|||||||
export class DotnetCoreInstaller {
|
export class DotnetCoreInstaller {
|
||||||
private static readonly FeatureBandSyntax = /^(\d+)\.(\d+)\.(\d)xx$/;
|
private static readonly FeatureBandSyntax = /^(\d+)\.(\d+)\.(\d)xx$/;
|
||||||
|
|
||||||
static {
|
|
||||||
DotnetInstallDir.setEnvironmentVariable();
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private version: string,
|
private version: string,
|
||||||
private quality: QualityOptions,
|
private quality: QualityOptions,
|
||||||
@@ -687,6 +772,9 @@ export class DotnetCoreInstaller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async installDotnet(): Promise<string | null> {
|
public async installDotnet(): Promise<string | null> {
|
||||||
|
// Before findLocalSdkVersion(), which looks under the resolved directory.
|
||||||
|
DotnetInstallDir.setEnvironmentVariable();
|
||||||
|
|
||||||
const isCrossArch =
|
const isCrossArch =
|
||||||
!!this.architecture &&
|
!!this.architecture &&
|
||||||
normalizeArch(this.architecture) !== normalizeArch(os.arch());
|
normalizeArch(this.architecture) !== normalizeArch(os.arch());
|
||||||
|
|||||||
Reference in new issue
Block a user