Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/501 #507

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93328,13 +93328,19 @@ const cache_utils_1 = __nccwpck_require__(1678);
const cache_restore_1 = __nccwpck_require__(9517);
const constants_1 = __nccwpck_require__(9042);
const json5_1 = __importDefault(__nccwpck_require__(6904));
const os = __importStar(__nccwpck_require__(2037));
const qualityOptions = [
'daily',
'signed',
'validated',
'preview',
'ga'
];
let cancelled = false;
let errorOccurred = false;
process.on('SIGINT', () => {
cancelled = true;
});
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
Expand Down Expand Up @@ -93376,6 +93382,9 @@ function run() {
let dotnetInstaller;
const uniqueVersions = new Set(versions);
for (const version of uniqueVersions) {
if (cancelled) {
throw new Error('Cancelled');
}
dotnetInstaller = new installer_1.DotnetCoreInstaller(version, quality);
const installedVersion = yield dotnetInstaller.installDotnet();
installedDotnetVersions.push(installedVersion);
Expand All @@ -93397,6 +93406,28 @@ function run() {
}
catch (error) {
core.setFailed(error.message);
errorOccurred = true;
}
finally {
if (errorOccurred || cancelled) {
console.log('Cleaning up...');
let directoryPath;
switch (os.platform()) {
case 'win32':
directoryPath = 'C:\\Program Files\\dotnet';
break;
case 'darwin':
directoryPath = '/usr/local/share/dotnet';
break;
case 'linux':
directoryPath = '/usr/share/dotnet';
break;
default:
throw new Error(`Unsupported platform: ${os.platform()}`);
}
fs.rmdirSync(directoryPath, { recursive: true });
console.log(`Directory ${directoryPath} has been deleted.`);
}
}
});
}
Expand Down
30 changes: 30 additions & 0 deletions setup-dotnet.sln
Original file line number Diff line number Diff line change
@@ -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
37 changes: 34 additions & 3 deletions src/setup-dotnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {isCacheFeatureAvailable} from './cache-utils';
import {restoreCache} from './cache-restore';
import {Outputs} from './constants';
import JSON5 from 'json5';
import * as os from 'os';

const qualityOptions = [
'daily',
Expand All @@ -19,6 +20,13 @@ const qualityOptions = [

export type QualityOptions = (typeof qualityOptions)[number];

let cancelled = false;
let errorOccurred = false;
const unsupportedPlatform = false;
process.on('SIGINT', () => {
cancelled = true;
});

export async function run() {
try {
//
Expand Down Expand Up @@ -69,6 +77,9 @@ export async function run() {
let dotnetInstaller: DotnetCoreInstaller;
const uniqueVersions = new Set<string>(versions);
for (const version of uniqueVersions) {
if (cancelled) {
throw new Error('Cancelled');
}
dotnetInstaller = new DotnetCoreInstaller(version, quality);
const installedVersion = await dotnetInstaller.installDotnet();
installedDotnetVersions.push(installedVersion);
Expand All @@ -88,11 +99,31 @@ export async function run() {
const cacheDependencyPath = core.getInput('cache-dependency-path');
await restoreCache(cacheDependencyPath);
}

const matchersPath = path.join(__dirname, '..', '..', '.github');
core.info(`##[add-matcher]${path.join(matchersPath, 'csc.json')}`);
} catch (error) {
core.setFailed(error.message);
errorOccurred = true;
} finally {
if (errorOccurred || cancelled) {
('Cleaning up...');
let directoryPath: string;
switch (os.platform()) {
case 'win32':
directoryPath = 'C:\\Program Files\\dotnet';
break;
case 'darwin':
directoryPath = '/usr/local/share/dotnet';
break;
case 'linux':
directoryPath = '/usr/share/dotnet';
break;
default:
directoryPath = 'Unsupported platform';
}
if (!unsupportedPlatform && fs.existsSync(directoryPath)) {
fs.rmdirSync(directoryPath, {recursive: true});
core.info(`Directory ${directoryPath} has been deleted.`);
}
}
}
}

Expand Down
Loading