try fixing 5.x issue

This commit is contained in:
Dmitry Shibanov 2021-03-17 12:38:57 +03:00
parent 77a48bbb85
commit 36fa9877a9
2 changed files with 29 additions and 12 deletions

16
dist/index.js vendored
View File

@ -16876,7 +16876,13 @@ class DotNetVersionInfo {
this.throwInvalidVersionFormat(); this.throwInvalidVersionFormat();
} }
let major = this.getVersionNumberOrThrow(parts[0]); let major = this.getVersionNumberOrThrow(parts[0]);
let minor = this.getVersionNumberOrThrow(parts[1]); let minor;
if (parts[1] === 'x') {
minor = parts[1];
}
else {
minor = this.getVersionNumberOrThrow(parts[1]);
}
this.fullversion = major + '.' + minor; this.fullversion = major + '.' + minor;
} }
getVersionNumberOrThrow(input) { getVersionNumberOrThrow(input) {
@ -16894,7 +16900,7 @@ class DotNetVersionInfo {
} }
} }
throwInvalidVersionFormat() { throwInvalidVersionFormat() {
throw 'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*'; throw new Error('Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*');
} }
/** /**
* If true exacatly one version should be resolved * If true exacatly one version should be resolved
@ -16997,7 +17003,7 @@ class DotnetCoreInstaller {
} }
console.log(process.env['PATH']); console.log(process.env['PATH']);
if (resultCode != 0) { if (resultCode != 0) {
throw `Failed to install dotnet ${resultCode}. ${output}`; throw new Error(`Failed to install dotnet ${resultCode}. ${output}`);
} }
}); });
} }
@ -17025,7 +17031,7 @@ class DotnetCoreInstaller {
// Sort for latest version // Sort for latest version
releasesInfo = releasesInfo.sort((a, b) => semver.rcompare(a['sdk']['version'], b['sdk']['version'])); releasesInfo = releasesInfo.sort((a, b) => semver.rcompare(a['sdk']['version'], b['sdk']['version']));
if (releasesInfo.length == 0) { if (releasesInfo.length == 0) {
throw `Could not find dotnet core version. Please ensure that specified version ${versionInfo.inputVersion} is valid.`; throw new Error(`Could not find dotnet core version. Please ensure that specified version ${versionInfo.inputVersion} is valid.`);
} }
let release = releasesInfo[0]; let release = releasesInfo[0];
return release['sdk']['version']; return release['sdk']['version'];
@ -17046,7 +17052,7 @@ class DotnetCoreInstaller {
return versionParts[0] == sdkParts[0]; return versionParts[0] == sdkParts[0];
}); });
if (releasesInfo.length === 0) { if (releasesInfo.length === 0) {
throw `Could not find info for version ${versionParts.join('.')} at ${DotNetCoreIndexUrl}`; throw new Error(`Could not find info for version ${versionParts.join('.')} at ${DotNetCoreIndexUrl}`);
} }
return releasesInfo[0]['releases.json']; return releasesInfo[0]['releases.json'];
}); });

View File

@ -39,7 +39,12 @@ export class DotNetVersionInfo {
} }
let major = this.getVersionNumberOrThrow(parts[0]); let major = this.getVersionNumberOrThrow(parts[0]);
let minor = this.getVersionNumberOrThrow(parts[1]); let minor;
if (parts[1] === 'x') {
minor = parts[1];
} else {
minor = this.getVersionNumberOrThrow(parts[1]);
}
this.fullversion = major + '.' + minor; this.fullversion = major + '.' + minor;
} }
@ -60,7 +65,9 @@ export class DotNetVersionInfo {
} }
private throwInvalidVersionFormat() { private throwInvalidVersionFormat() {
throw 'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*'; throw new Error(
'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*'
);
} }
/** /**
@ -187,7 +194,7 @@ export class DotnetCoreInstaller {
console.log(process.env['PATH']); console.log(process.env['PATH']);
if (resultCode != 0) { if (resultCode != 0) {
throw `Failed to install dotnet ${resultCode}. ${output}`; throw new Error(`Failed to install dotnet ${resultCode}. ${output}`);
} }
} }
@ -236,7 +243,9 @@ export class DotnetCoreInstaller {
); );
if (releasesInfo.length == 0) { if (releasesInfo.length == 0) {
throw `Could not find dotnet core version. Please ensure that specified version ${versionInfo.inputVersion} is valid.`; throw new Error(
`Could not find dotnet core version. Please ensure that specified version ${versionInfo.inputVersion} is valid.`
);
} }
let release = releasesInfo[0]; let release = releasesInfo[0];
@ -264,9 +273,11 @@ export class DotnetCoreInstaller {
}); });
if (releasesInfo.length === 0) { if (releasesInfo.length === 0) {
throw `Could not find info for version ${versionParts.join( throw new Error(
'.' `Could not find info for version ${versionParts.join(
)} at ${DotNetCoreIndexUrl}`; '.'
)} at ${DotNetCoreIndexUrl}`
);
} }
return releasesInfo[0]['releases.json']; return releasesInfo[0]['releases.json'];