mirror of
https://github.com/actions/setup-dotnet.git
synced 2025-08-20 23:50:19 +00:00
add seperate method to add to Path
This commit is contained in:
parent
866d7435eb
commit
fe6123a5c5
@ -38,6 +38,7 @@ describe('installer tests', () => {
|
|||||||
for (const version of versions) {
|
for (const version of versions) {
|
||||||
await getDotnet(version);
|
await getDotnet(version);
|
||||||
}
|
}
|
||||||
|
installer.DotnetCoreInstaller.addToPath();
|
||||||
expect(fs.existsSync(path.join(toolDir, 'sdk', '2.2.207'))).toBe(true);
|
expect(fs.existsSync(path.join(toolDir, 'sdk', '2.2.207'))).toBe(true);
|
||||||
expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.120'))).toBe(true);
|
expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.120'))).toBe(true);
|
||||||
|
|
||||||
@ -55,6 +56,7 @@ describe('installer tests', () => {
|
|||||||
|
|
||||||
it('Acquires version of dotnet if no matching version is installed', async () => {
|
it('Acquires version of dotnet if no matching version is installed', async () => {
|
||||||
await getDotnet('3.1.201');
|
await getDotnet('3.1.201');
|
||||||
|
installer.DotnetCoreInstaller.addToPath();
|
||||||
expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.201'))).toBe(true);
|
expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.201'))).toBe(true);
|
||||||
if (IS_WINDOWS) {
|
if (IS_WINDOWS) {
|
||||||
expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true);
|
expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true);
|
||||||
@ -70,6 +72,7 @@ describe('installer tests', () => {
|
|||||||
|
|
||||||
it('Acquires generic version of dotnet if no matching version is installed', async () => {
|
it('Acquires generic version of dotnet if no matching version is installed', async () => {
|
||||||
await getDotnet('3.1');
|
await getDotnet('3.1');
|
||||||
|
installer.DotnetCoreInstaller.addToPath();
|
||||||
var directory = fs
|
var directory = fs
|
||||||
.readdirSync(path.join(toolDir, 'sdk'))
|
.readdirSync(path.join(toolDir, 'sdk'))
|
||||||
.filter(fn => fn.startsWith('3.1.'));
|
.filter(fn => fn.startsWith('3.1.'));
|
||||||
|
39
dist/index.js
vendored
39
dist/index.js
vendored
@ -8683,7 +8683,7 @@ function run() {
|
|||||||
versions[0] = getVersionFromGlobalJson(globalJsonPath);
|
versions[0] = getVersionFromGlobalJson(globalJsonPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (versions) {
|
if (versions.length) {
|
||||||
const includePrerelease = (core.getInput('include-prerelease') || 'false').toLowerCase() ===
|
const includePrerelease = (core.getInput('include-prerelease') || 'false').toLowerCase() ===
|
||||||
'true';
|
'true';
|
||||||
let dotnetInstaller;
|
let dotnetInstaller;
|
||||||
@ -8691,6 +8691,7 @@ function run() {
|
|||||||
dotnetInstaller = new installer.DotnetCoreInstaller(version, includePrerelease);
|
dotnetInstaller = new installer.DotnetCoreInstaller(version, includePrerelease);
|
||||||
yield dotnetInstaller.installDotnet();
|
yield dotnetInstaller.installDotnet();
|
||||||
}
|
}
|
||||||
|
installer.DotnetCoreInstaller.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');
|
||||||
@ -18103,28 +18104,30 @@ class DotnetCoreInstaller {
|
|||||||
env: envVariables
|
env: envVariables
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (process.env['DOTNET_INSTALL_DIR']) {
|
|
||||||
core.addPath(process.env['DOTNET_INSTALL_DIR']);
|
|
||||||
core.exportVariable('DOTNET_ROOT', process.env['DOTNET_INSTALL_DIR']);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
// This is the default set in install-dotnet.ps1
|
|
||||||
core.addPath(path.join(process.env['LocalAppData'] + '', 'Microsoft', 'dotnet'));
|
|
||||||
core.exportVariable('DOTNET_ROOT', path.join(process.env['LocalAppData'] + '', 'Microsoft', 'dotnet'));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// This is the default set in install-dotnet.sh
|
|
||||||
core.addPath(path.join(process.env['HOME'] + '', '.dotnet'));
|
|
||||||
core.exportVariable('DOTNET_ROOT', path.join(process.env['HOME'] + '', '.dotnet'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.log(process.env['PATH']);
|
|
||||||
if (resultCode != 0) {
|
if (resultCode != 0) {
|
||||||
throw new Error(`Failed to install dotnet ${resultCode}. ${output}`);
|
throw new Error(`Failed to install dotnet ${resultCode}. ${output}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
static addToPath() {
|
||||||
|
if (process.env['DOTNET_INSTALL_DIR']) {
|
||||||
|
core.addPath(process.env['DOTNET_INSTALL_DIR']);
|
||||||
|
core.exportVariable('DOTNET_ROOT', process.env['DOTNET_INSTALL_DIR']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (IS_WINDOWS) {
|
||||||
|
// This is the default set in install-dotnet.ps1
|
||||||
|
core.addPath(path.join(process.env['LocalAppData'] + '', 'Microsoft', 'dotnet'));
|
||||||
|
core.exportVariable('DOTNET_ROOT', path.join(process.env['LocalAppData'] + '', 'Microsoft', 'dotnet'));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// This is the default set in install-dotnet.sh
|
||||||
|
core.addPath(path.join(process.env['HOME'] + '', '.dotnet'));
|
||||||
|
core.exportVariable('DOTNET_ROOT', path.join(process.env['HOME'] + '', '.dotnet'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(process.env['PATH']);
|
||||||
|
}
|
||||||
// versionInfo - versionInfo of the SDK/Runtime
|
// versionInfo - versionInfo of the SDK/Runtime
|
||||||
resolveVersion(versionInfo) {
|
resolveVersion(versionInfo) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
@ -164,6 +164,13 @@ export class DotnetCoreInstaller {
|
|||||||
env: envVariables
|
env: envVariables
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (resultCode != 0) {
|
||||||
|
throw new Error(`Failed to install dotnet ${resultCode}. ${output}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static addToPath() {
|
||||||
if (process.env['DOTNET_INSTALL_DIR']) {
|
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']);
|
||||||
@ -188,10 +195,6 @@ export class DotnetCoreInstaller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log(process.env['PATH']);
|
console.log(process.env['PATH']);
|
||||||
|
|
||||||
if (resultCode != 0) {
|
|
||||||
throw new Error(`Failed to install dotnet ${resultCode}. ${output}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// versionInfo - versionInfo of the SDK/Runtime
|
// versionInfo - versionInfo of the SDK/Runtime
|
||||||
|
@ -23,11 +23,11 @@ export async function run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (versions) {
|
if (versions.length) {
|
||||||
const includePrerelease: boolean =
|
const includePrerelease: boolean =
|
||||||
(core.getInput('include-prerelease') || 'false').toLowerCase() ===
|
(core.getInput('include-prerelease') || 'false').toLowerCase() ===
|
||||||
'true';
|
'true';
|
||||||
let dotnetInstaller: installer.DotnetCoreInstaller;
|
let dotnetInstaller!: installer.DotnetCoreInstaller;
|
||||||
for (const version of versions) {
|
for (const version of versions) {
|
||||||
dotnetInstaller = new installer.DotnetCoreInstaller(
|
dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||||
version,
|
version,
|
||||||
@ -35,6 +35,7 @@ export async function run() {
|
|||||||
);
|
);
|
||||||
await dotnetInstaller.installDotnet();
|
await dotnetInstaller.installDotnet();
|
||||||
}
|
}
|
||||||
|
installer.DotnetCoreInstaller.addToPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
const sourceUrl: string = core.getInput('source-url');
|
const sourceUrl: string = core.getInput('source-url');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user