This commit is contained in:
shaanmugapriya 2024-02-14 12:13:49 +05:30 committed by GitHub
commit 6bf15797f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 95 additions and 3 deletions

31
dist/setup/index.js vendored
View File

@ -93328,6 +93328,7 @@ 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',
@ -93335,6 +93336,11 @@ const qualityOptions = [
'preview',
'ga'
];
let cancelled = false;
let errorOccurred = false;
process.on('SIGINT', () => {
cancelled = true;
});
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
@ -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);
@ -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.`);
}
}
});
}

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

@ -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',
@ -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 {
//
@ -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);
@ -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.`);
}
}
}
}