Updated code to fix 501

This commit is contained in:
shaanmugapriya 2024-02-12 14:10:45 +05:30
parent 4d6c8fcf3c
commit d03d4fe9c6
3 changed files with 56 additions and 4 deletions

16
dist/setup/index.js vendored
View File

@ -93335,6 +93335,10 @@ const qualityOptions = [
'preview', 'preview',
'ga' 'ga'
]; ];
let cancelled = false;
process.on('SIGINT', () => {
cancelled = true;
});
function run() { function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
@ -93358,8 +93362,6 @@ function run() {
versions.push(getVersionFromGlobalJson(globalJsonPath)); versions.push(getVersionFromGlobalJson(globalJsonPath));
} }
if (!versions.length) { if (!versions.length) {
// Try to fall back to global.json
core.debug('No version found, trying to find version from global.json');
const globalJsonPath = path_1.default.join(process.cwd(), 'global.json'); const globalJsonPath = path_1.default.join(process.cwd(), 'global.json');
if (fs.existsSync(globalJsonPath)) { if (fs.existsSync(globalJsonPath)) {
versions.push(getVersionFromGlobalJson(globalJsonPath)); versions.push(getVersionFromGlobalJson(globalJsonPath));
@ -93376,6 +93378,9 @@ function run() {
let dotnetInstaller; let dotnetInstaller;
const uniqueVersions = new Set(versions); const uniqueVersions = new Set(versions);
for (const version of uniqueVersions) { for (const version of uniqueVersions) {
if (cancelled) {
throw new Error('Cancelled');
}
dotnetInstaller = new installer_1.DotnetCoreInstaller(version, quality); dotnetInstaller = new installer_1.DotnetCoreInstaller(version, quality);
const installedVersion = yield dotnetInstaller.installDotnet(); const installedVersion = yield dotnetInstaller.installDotnet();
installedDotnetVersions.push(installedVersion); installedDotnetVersions.push(installedVersion);
@ -93396,7 +93401,12 @@ function run() {
core.info(`##[add-matcher]${path_1.default.join(matchersPath, 'csc.json')}`); core.info(`##[add-matcher]${path_1.default.join(matchersPath, 'csc.json')}`);
} }
catch (error) { catch (error) {
core.setFailed(error.message); if (error.message === 'Cancelled') {
console.log('Cleaning up...');
}
else {
core.setFailed(error.message);
}
} }
}); });
} }

30
setup-dotnet.sln Normal file
View File

@ -0,0 +1,30 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "__tests__", "__tests__", "{4EBCF652-9B47-4590-A4F4-9AFC5FB9AB16}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "test", "__tests__\e2e-test-csproj\test.csproj", "{BF96E0E1-5384-4445-92C8-B9B999FD812E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BF96E0E1-5384-4445-92C8-B9B999FD812E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BF96E0E1-5384-4445-92C8-B9B999FD812E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BF96E0E1-5384-4445-92C8-B9B999FD812E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BF96E0E1-5384-4445-92C8-B9B999FD812E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{BF96E0E1-5384-4445-92C8-B9B999FD812E} = {4EBCF652-9B47-4590-A4F4-9AFC5FB9AB16}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7249446B-27CA-4F79-B35C-1575C52AFB5D}
EndGlobalSection
EndGlobal

View File

@ -19,6 +19,11 @@ const qualityOptions = [
export type QualityOptions = (typeof qualityOptions)[number]; export type QualityOptions = (typeof qualityOptions)[number];
let cancelled = false;
process.on('SIGINT', () => {
cancelled = true;
});
export async function run() { export async function run() {
try { try {
// //
@ -69,6 +74,9 @@ export async function run() {
let dotnetInstaller: DotnetCoreInstaller; let dotnetInstaller: DotnetCoreInstaller;
const uniqueVersions = new Set<string>(versions); const uniqueVersions = new Set<string>(versions);
for (const version of uniqueVersions) { for (const version of uniqueVersions) {
if (cancelled) {
throw new Error('Cancelled');
}
dotnetInstaller = new DotnetCoreInstaller(version, quality); dotnetInstaller = new DotnetCoreInstaller(version, quality);
const installedVersion = await dotnetInstaller.installDotnet(); const installedVersion = await dotnetInstaller.installDotnet();
installedDotnetVersions.push(installedVersion); installedDotnetVersions.push(installedVersion);
@ -92,7 +100,11 @@ export async function run() {
const matchersPath = path.join(__dirname, '..', '..', '.github'); const matchersPath = path.join(__dirname, '..', '..', '.github');
core.info(`##[add-matcher]${path.join(matchersPath, 'csc.json')}`); core.info(`##[add-matcher]${path.join(matchersPath, 'csc.json')}`);
} catch (error) { } catch (error) {
core.setFailed(error.message); if (error.message === 'Cancelled') {
'Cleaning up...';
} else {
core.setFailed(error.message);
}
} }
} }