mirror of
https://github.com/actions/setup-dotnet.git
synced 2025-08-20 23:50:19 +00:00
removed dotnet-versions input & refactored tests
This commit is contained in:
parent
d7c11d972b
commit
1745ec626e
@ -34,7 +34,7 @@ describe('installer tests', () => {
|
|||||||
|
|
||||||
it('Aquires multiple versions of dotnet', async () => {
|
it('Aquires multiple versions of dotnet', async () => {
|
||||||
const versions = ['2.2.207', '3.1.120'];
|
const versions = ['2.2.207', '3.1.120'];
|
||||||
await getDotnetVersions(versions);
|
await getDotnet(versions);
|
||||||
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);
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ describe('installer tests', () => {
|
|||||||
}, 600000);
|
}, 600000);
|
||||||
|
|
||||||
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']);
|
||||||
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);
|
||||||
@ -66,7 +66,7 @@ describe('installer tests', () => {
|
|||||||
}, 600000); //This needs some time to download on "slower" internet connections
|
}, 600000); //This needs some time to download on "slower" internet connections
|
||||||
|
|
||||||
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']);
|
||||||
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.'));
|
||||||
@ -86,7 +86,7 @@ describe('installer tests', () => {
|
|||||||
it('Throws if no location contains correct dotnet version', async () => {
|
it('Throws if no location contains correct dotnet version', async () => {
|
||||||
let thrown = false;
|
let thrown = false;
|
||||||
try {
|
try {
|
||||||
await getDotnet('1000.0.0');
|
await getDotnet(['1000.0.0']);
|
||||||
} catch {
|
} catch {
|
||||||
thrown = true;
|
thrown = true;
|
||||||
}
|
}
|
||||||
@ -141,11 +141,7 @@ function normalizeFileContents(contents: string): string {
|
|||||||
.replace(new RegExp('\r', 'g'), '\n');
|
.replace(new RegExp('\r', 'g'), '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getDotnet(version: string): Promise<void> {
|
async function getDotnet(versions: string[]): Promise<void> {
|
||||||
const dotnetInstaller = new installer.DotnetCoreInstaller(version);
|
const dotnetInstaller = new installer.DotnetCoreInstaller(versions);
|
||||||
await dotnetInstaller.installDotnet();
|
await dotnetInstaller.installDotnet();
|
||||||
}
|
}
|
||||||
async function getDotnetVersions(versions: string[]): Promise<void> {
|
|
||||||
const dotnetInstaller = new installer.DotnetCoreInstaller('', versions);
|
|
||||||
await dotnetInstaller.installDotnetVersions();
|
|
||||||
}
|
|
||||||
|
@ -53,10 +53,10 @@ describe('setup-dotnet tests', () => {
|
|||||||
fs.writeFileSync(globalJsonPath, jsonContents);
|
fs.writeFileSync(globalJsonPath, jsonContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
const version = '3.1';
|
const version = ['3.1'];
|
||||||
const installer = new dotnetInstaller.DotnetCoreInstaller(version);
|
const installer = new dotnetInstaller.DotnetCoreInstaller(version);
|
||||||
const patchVersion = await installer.resolveVersion(
|
const patchVersion = await installer.resolveVersion(
|
||||||
new dotnetInstaller.DotNetVersionInfo(version)
|
new dotnetInstaller.DotNetVersionInfo(version[0])
|
||||||
);
|
);
|
||||||
await setup.run();
|
await setup.run();
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ describe('version tests', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
it('Resolving a nonexistent generic version fails', async () => {
|
it('Resolving a nonexistent generic version fails', async () => {
|
||||||
const dotnetInstaller = new installer.DotnetCoreInstaller('999.1.x');
|
const dotnetInstaller = new installer.DotnetCoreInstaller(['999.1.x']);
|
||||||
try {
|
try {
|
||||||
await dotnetInstaller.resolveVersion(
|
await dotnetInstaller.resolveVersion(
|
||||||
new installer.DotNetVersionInfo('999.1.x')
|
new installer.DotNetVersionInfo('999.1.x')
|
||||||
|
155
dist/index.js
vendored
155
dist/index.js
vendored
@ -8674,29 +8674,19 @@ function run() {
|
|||||||
// If a valid version still can't be identified, nothing will be installed.
|
// If a valid version still can't be identified, nothing will be installed.
|
||||||
// Proxy, auth, (etc) are still set up, even if no version is identified
|
// Proxy, auth, (etc) are still set up, even if no version is identified
|
||||||
//
|
//
|
||||||
let version = core.getInput('dotnet-version');
|
let versions = core.getMultilineInput('dotnet-version');
|
||||||
let versions = core.getMultilineInput('dotnet-versions');
|
if (!versions.length) {
|
||||||
if (!version && !versions.length) {
|
|
||||||
// Try to fall back to global.json
|
// Try to fall back to global.json
|
||||||
core.debug('No version found, trying to find version from global.json');
|
core.debug('No version found, trying to find version from global.json');
|
||||||
const globalJsonPath = path.join(process.cwd(), 'global.json');
|
const globalJsonPath = path.join(process.cwd(), 'global.json');
|
||||||
if (fs.existsSync(globalJsonPath)) {
|
if (fs.existsSync(globalJsonPath)) {
|
||||||
version = getVersionFromGlobalJson(globalJsonPath);
|
versions[0] = getVersionFromGlobalJson(globalJsonPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (version && versions) {
|
if (versions) {
|
||||||
core.warning("Multiple version inputs have been specified, Please specify either 'dotnet-version' or 'dotnet-versions'");
|
|
||||||
}
|
|
||||||
if (versions && !version) {
|
|
||||||
const includePrerelease = (core.getInput('include-prerelease') || 'false').toLowerCase() ===
|
const includePrerelease = (core.getInput('include-prerelease') || 'false').toLowerCase() ===
|
||||||
'true';
|
'true';
|
||||||
const dotnetInstaller = new installer.DotnetCoreInstaller('', versions, includePrerelease);
|
const dotnetInstaller = new installer.DotnetCoreInstaller(versions, includePrerelease);
|
||||||
yield dotnetInstaller.installDotnetVersions();
|
|
||||||
}
|
|
||||||
if (version) {
|
|
||||||
const includePrerelease = (core.getInput('include-prerelease') || 'false').toLowerCase() ===
|
|
||||||
'true';
|
|
||||||
const dotnetInstaller = new installer.DotnetCoreInstaller(version, [], includePrerelease);
|
|
||||||
yield dotnetInstaller.installDotnet();
|
yield dotnetInstaller.installDotnet();
|
||||||
}
|
}
|
||||||
const sourceUrl = core.getInput('source-url');
|
const sourceUrl = core.getInput('source-url');
|
||||||
@ -18045,102 +18035,11 @@ class DotNetVersionInfo {
|
|||||||
}
|
}
|
||||||
exports.DotNetVersionInfo = DotNetVersionInfo;
|
exports.DotNetVersionInfo = DotNetVersionInfo;
|
||||||
class DotnetCoreInstaller {
|
class DotnetCoreInstaller {
|
||||||
constructor(version, versions = [], includePrerelease = false) {
|
constructor(versions, includePrerelease = false) {
|
||||||
this.version = version;
|
|
||||||
this.versions = versions;
|
this.versions = versions;
|
||||||
this.includePrerelease = includePrerelease;
|
this.includePrerelease = includePrerelease;
|
||||||
}
|
}
|
||||||
installDotnet() {
|
installDotnet() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let output = '';
|
|
||||||
let resultCode = 0;
|
|
||||||
let calculatedVersion = yield this.resolveVersion(new DotNetVersionInfo(this.version));
|
|
||||||
var envVariables = {};
|
|
||||||
for (let key in process.env) {
|
|
||||||
if (process.env[key]) {
|
|
||||||
let value = process.env[key];
|
|
||||||
envVariables[key] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
let escapedScript = path
|
|
||||||
.join(__dirname, '..', 'externals', 'install-dotnet.ps1')
|
|
||||||
.replace(/'/g, "''");
|
|
||||||
let command = `& '${escapedScript}'`;
|
|
||||||
if (calculatedVersion) {
|
|
||||||
command += ` -Version ${calculatedVersion}`;
|
|
||||||
}
|
|
||||||
if (process.env['https_proxy'] != null) {
|
|
||||||
command += ` -ProxyAddress ${process.env['https_proxy']}`;
|
|
||||||
}
|
|
||||||
// This is not currently an option
|
|
||||||
if (process.env['no_proxy'] != null) {
|
|
||||||
command += ` -ProxyBypassList ${process.env['no_proxy']}`;
|
|
||||||
}
|
|
||||||
// process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
|
|
||||||
const powershellPath = yield io.which('powershell', true);
|
|
||||||
var options = {
|
|
||||||
listeners: {
|
|
||||||
stdout: (data) => {
|
|
||||||
output += data.toString();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
env: envVariables
|
|
||||||
};
|
|
||||||
resultCode = yield exec.exec(`"${powershellPath}"`, [
|
|
||||||
'-NoLogo',
|
|
||||||
'-Sta',
|
|
||||||
'-NoProfile',
|
|
||||||
'-NonInteractive',
|
|
||||||
'-ExecutionPolicy',
|
|
||||||
'Unrestricted',
|
|
||||||
'-Command',
|
|
||||||
command
|
|
||||||
], options);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
let escapedScript = path
|
|
||||||
.join(__dirname, '..', 'externals', 'install-dotnet.sh')
|
|
||||||
.replace(/'/g, "''");
|
|
||||||
fs_1.chmodSync(escapedScript, '777');
|
|
||||||
const scriptPath = yield io.which(escapedScript, true);
|
|
||||||
let scriptArguments = [];
|
|
||||||
if (calculatedVersion) {
|
|
||||||
scriptArguments.push('--version', calculatedVersion);
|
|
||||||
}
|
|
||||||
// process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
|
|
||||||
resultCode = yield exec.exec(`"${scriptPath}"`, scriptArguments, {
|
|
||||||
listeners: {
|
|
||||||
stdout: (data) => {
|
|
||||||
output += data.toString();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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) {
|
|
||||||
throw new Error(`Failed to install dotnet ${resultCode}. ${output}`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
installDotnetVersions() {
|
|
||||||
var e_1, _a;
|
var e_1, _a;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let output = '';
|
let output = '';
|
||||||
@ -18148,7 +18047,7 @@ class DotnetCoreInstaller {
|
|||||||
try {
|
try {
|
||||||
for (var _b = __asyncValues(this.versions), _c; _c = yield _b.next(), !_c.done;) {
|
for (var _b = __asyncValues(this.versions), _c; _c = yield _b.next(), !_c.done;) {
|
||||||
const version = _c.value;
|
const version = _c.value;
|
||||||
let calculatedVersion = yield this.resolveVersion(new DotNetVersionInfo(version.trim()));
|
let calculatedVersion = yield this.resolveVersion(new DotNetVersionInfo(version));
|
||||||
var envVariables = {};
|
var envVariables = {};
|
||||||
for (let key in process.env) {
|
for (let key in process.env) {
|
||||||
if (process.env[key]) {
|
if (process.env[key]) {
|
||||||
@ -18212,26 +18111,6 @@ 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) {
|
|
||||||
throw new Error(`Failed to install dotnet ${resultCode}. ${output}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||||
@ -18241,6 +18120,26 @@ class DotnetCoreInstaller {
|
|||||||
}
|
}
|
||||||
finally { if (e_1) throw e_1.error; }
|
finally { if (e_1) throw e_1.error; }
|
||||||
}
|
}
|
||||||
|
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) {
|
||||||
|
throw new Error(`Failed to install dotnet ${resultCode}. ${output}`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// versionInfo - versionInfo of the SDK/Runtime
|
// versionInfo - versionInfo of the SDK/Runtime
|
||||||
|
169
src/installer.ts
169
src/installer.ts
@ -79,12 +79,7 @@ export class DotNetVersionInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class DotnetCoreInstaller {
|
export class DotnetCoreInstaller {
|
||||||
constructor(
|
constructor(versions: string[], includePrerelease: boolean = false) {
|
||||||
version: string,
|
|
||||||
versions: string[] = [],
|
|
||||||
includePrerelease: boolean = false
|
|
||||||
) {
|
|
||||||
this.version = version;
|
|
||||||
this.versions = versions;
|
this.versions = versions;
|
||||||
this.includePrerelease = includePrerelease;
|
this.includePrerelease = includePrerelease;
|
||||||
}
|
}
|
||||||
@ -93,119 +88,9 @@ export class DotnetCoreInstaller {
|
|||||||
let output = '';
|
let output = '';
|
||||||
let resultCode = 0;
|
let resultCode = 0;
|
||||||
|
|
||||||
let calculatedVersion = await this.resolveVersion(
|
|
||||||
new DotNetVersionInfo(this.version)
|
|
||||||
);
|
|
||||||
|
|
||||||
var envVariables: {[key: string]: string} = {};
|
|
||||||
for (let key in process.env) {
|
|
||||||
if (process.env[key]) {
|
|
||||||
let value: any = process.env[key];
|
|
||||||
envVariables[key] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
let escapedScript = path
|
|
||||||
.join(__dirname, '..', 'externals', 'install-dotnet.ps1')
|
|
||||||
.replace(/'/g, "''");
|
|
||||||
let command = `& '${escapedScript}'`;
|
|
||||||
if (calculatedVersion) {
|
|
||||||
command += ` -Version ${calculatedVersion}`;
|
|
||||||
}
|
|
||||||
if (process.env['https_proxy'] != null) {
|
|
||||||
command += ` -ProxyAddress ${process.env['https_proxy']}`;
|
|
||||||
}
|
|
||||||
// This is not currently an option
|
|
||||||
if (process.env['no_proxy'] != null) {
|
|
||||||
command += ` -ProxyBypassList ${process.env['no_proxy']}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
|
|
||||||
const powershellPath = await io.which('powershell', true);
|
|
||||||
|
|
||||||
var options: ExecOptions = {
|
|
||||||
listeners: {
|
|
||||||
stdout: (data: Buffer) => {
|
|
||||||
output += data.toString();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
env: envVariables
|
|
||||||
};
|
|
||||||
|
|
||||||
resultCode = await exec.exec(
|
|
||||||
`"${powershellPath}"`,
|
|
||||||
[
|
|
||||||
'-NoLogo',
|
|
||||||
'-Sta',
|
|
||||||
'-NoProfile',
|
|
||||||
'-NonInteractive',
|
|
||||||
'-ExecutionPolicy',
|
|
||||||
'Unrestricted',
|
|
||||||
'-Command',
|
|
||||||
command
|
|
||||||
],
|
|
||||||
options
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
let escapedScript = path
|
|
||||||
.join(__dirname, '..', 'externals', 'install-dotnet.sh')
|
|
||||||
.replace(/'/g, "''");
|
|
||||||
chmodSync(escapedScript, '777');
|
|
||||||
|
|
||||||
const scriptPath = await io.which(escapedScript, true);
|
|
||||||
|
|
||||||
let scriptArguments: string[] = [];
|
|
||||||
if (calculatedVersion) {
|
|
||||||
scriptArguments.push('--version', calculatedVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
// process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
|
|
||||||
resultCode = await exec.exec(`"${scriptPath}"`, scriptArguments, {
|
|
||||||
listeners: {
|
|
||||||
stdout: (data: Buffer) => {
|
|
||||||
output += data.toString();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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) {
|
|
||||||
throw new Error(`Failed to install dotnet ${resultCode}. ${output}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async installDotnetVersions() {
|
|
||||||
let output = '';
|
|
||||||
let resultCode = 0;
|
|
||||||
for await (const version of this.versions) {
|
for await (const version of this.versions) {
|
||||||
let calculatedVersion = await this.resolveVersion(
|
let calculatedVersion = await this.resolveVersion(
|
||||||
new DotNetVersionInfo(version.trim())
|
new DotNetVersionInfo(version)
|
||||||
);
|
);
|
||||||
|
|
||||||
var envVariables: {[key: string]: string} = {};
|
var envVariables: {[key: string]: string} = {};
|
||||||
@ -280,35 +165,34 @@ export class DotnetCoreInstaller {
|
|||||||
env: envVariables
|
env: envVariables
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
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']);
|
||||||
|
} 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 {
|
} else {
|
||||||
if (IS_WINDOWS) {
|
// This is the default set in install-dotnet.sh
|
||||||
// This is the default set in install-dotnet.ps1
|
core.addPath(path.join(process.env['HOME'] + '', '.dotnet'));
|
||||||
core.addPath(
|
core.exportVariable(
|
||||||
path.join(process.env['LocalAppData'] + '', 'Microsoft', 'dotnet')
|
'DOTNET_ROOT',
|
||||||
);
|
path.join(process.env['HOME'] + '', '.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']);
|
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}`);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,7 +287,6 @@ export class DotnetCoreInstaller {
|
|||||||
return releasesInfo[0]['releases.json'];
|
return releasesInfo[0]['releases.json'];
|
||||||
}
|
}
|
||||||
|
|
||||||
private version: string;
|
|
||||||
private versions: string[];
|
private versions: string[];
|
||||||
private includePrerelease: boolean;
|
private includePrerelease: boolean;
|
||||||
}
|
}
|
||||||
|
@ -13,43 +13,25 @@ export async function run() {
|
|||||||
// If a valid version still can't be identified, nothing will be installed.
|
// If a valid version still can't be identified, nothing will be installed.
|
||||||
// Proxy, auth, (etc) are still set up, even if no version is identified
|
// Proxy, auth, (etc) are still set up, even if no version is identified
|
||||||
//
|
//
|
||||||
let version = core.getInput('dotnet-version');
|
let versions = core.getMultilineInput('dotnet-version');
|
||||||
let versions = core.getMultilineInput('dotnet-versions');
|
if (!versions.length) {
|
||||||
if (!version && !versions.length) {
|
|
||||||
// Try to fall back to global.json
|
// Try to fall back to global.json
|
||||||
core.debug('No version found, trying to find version from global.json');
|
core.debug('No version found, trying to find version from global.json');
|
||||||
const globalJsonPath = path.join(process.cwd(), 'global.json');
|
const globalJsonPath = path.join(process.cwd(), 'global.json');
|
||||||
if (fs.existsSync(globalJsonPath)) {
|
if (fs.existsSync(globalJsonPath)) {
|
||||||
version = getVersionFromGlobalJson(globalJsonPath);
|
versions[0] = getVersionFromGlobalJson(globalJsonPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (version && versions) {
|
|
||||||
core.warning(
|
if (versions) {
|
||||||
"Multiple version inputs have been specified, Please specify either 'dotnet-version' or 'dotnet-versions'"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (versions && !version) {
|
|
||||||
const includePrerelease: boolean =
|
const includePrerelease: boolean =
|
||||||
(core.getInput('include-prerelease') || 'false').toLowerCase() ===
|
(core.getInput('include-prerelease') || 'false').toLowerCase() ===
|
||||||
'true';
|
'true';
|
||||||
|
|
||||||
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||||
'',
|
|
||||||
versions,
|
versions,
|
||||||
includePrerelease
|
includePrerelease
|
||||||
);
|
);
|
||||||
await dotnetInstaller.installDotnetVersions();
|
|
||||||
}
|
|
||||||
if (version) {
|
|
||||||
const includePrerelease: boolean =
|
|
||||||
(core.getInput('include-prerelease') || 'false').toLowerCase() ===
|
|
||||||
'true';
|
|
||||||
|
|
||||||
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
|
||||||
version,
|
|
||||||
[],
|
|
||||||
includePrerelease
|
|
||||||
);
|
|
||||||
await dotnetInstaller.installDotnet();
|
await dotnetInstaller.installDotnet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user