Consider when the user Cancels the SDK Installer on Mac (#1993)

* Try asking the user if the want to continue

* Add a message on mac if someone tries to cancel the installation

Consider that to tell if the user wanted to say 'no' or 'yes' to retry, that doesnt indicate whether they meant to do the install or not. We would then need more options to tell if we actually failed or not. I dont want to rely on this and I dont think it is a high enough priority with the complexity required to reroute the code to add a retry button that does a certain retry depending on if someone clicked to cancel the install on mac

* Consider if the dotnet file doesnt exist but the folder does

* Fix bug
This commit is contained in:
Noah Gilson 2024-10-16 16:55:55 -07:00 коммит произвёл GitHub
Родитель 2282514595
Коммит 13e2bf6e6c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 21 добавлений и 32 удалений

Просмотреть файл

@ -505,35 +505,7 @@ ${WinMacGlobalInstaller.InterpretExitCode(installerResult)}`), install);
dotnetPath = await installer.getExpectedGlobalSDKPath(installingVersion,
context.acquisitionContext.architecture ?? this.getDefaultInternalArchitecture(context.acquisitionContext.architecture));
try
{
context.installationValidator.validateDotnetInstall(install, dotnetPath, os.platform() !== 'win32');
}
catch(error : any)
{
if(os.platform() === 'darwin')
{
const executor = new CommandExecutor(context, this.utilityContext);
const result = await executor.execute(CommandExecutor.makeCommand('which', ['dotnet']));
if(result?.status === '0')
{
context.eventStream.post(new DotnetInstallationValidated(install));
dotnetPath = result.stdout;
}
else
{
// Remove this when https://github.com/typescript-eslint/typescript-eslint/issues/2728 is done
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
error.message ??= 'The .NET SDK installer did not install the SDK correctly.';
// Remove this when https://github.com/typescript-eslint/typescript-eslint/issues/2728 is done
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
error.message += `Which dotnet returned ${result?.stdout} and ${result?.stderr}.`;
throw error;
}
}
throw error;
}
context.installationValidator.validateDotnetInstall(install, dotnetPath, os.platform() !== 'win32', os.platform() !== 'darwin');
context.eventStream.post(new DotnetAcquisitionCompleted(install, dotnetPath, installingVersion));

Просмотреть файл

@ -3,6 +3,7 @@
* The .NET Foundation licenses this file to you under the MIT license.
*--------------------------------------------------------------------------------------------*/
import { IDotnetAcquireContext, IVSCodeExtensionContext } from '..';
import { IEventStream } from '../EventStream/EventStream';
import { DotnetInstall } from './DotnetInstall';

Просмотреть файл

@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as fs from 'fs';
import * as path from 'path';
import * as os from 'os';
import {
DotnetInstallationValidated,
DotnetInstallationValidationError,
@ -34,8 +35,16 @@ export class InstallationValidator extends IInstallationValidator {
this.assertOrThrowError(failOnErr, fs.existsSync(folder),
`${dotnetValidationFailed} Expected dotnet folder ${dotnetPath} does not exist.`, install, dotnetPath);
this.assertOrThrowError(failOnErr, fs.readdirSync(folder).length !== 0,
`${dotnetValidationFailed} The dotnet folder is empty "${dotnetPath}"`, install, dotnetPath);
try
{
this.assertOrThrowError(failOnErr, fs.readdirSync(folder).length !== 0,
`${dotnetValidationFailed} The dotnet folder is empty "${dotnetPath}"`, install, dotnetPath);
}
catch(error : any) // fs.readdirsync throws ENOENT so we need to recall the function
{
this.assertOrThrowError(failOnErr, false,
`${dotnetValidationFailed} The dotnet file dne "${dotnetPath}"`, install, dotnetPath);
}
}
this.eventStream.post(new DotnetInstallationValidated(install));
@ -47,7 +56,14 @@ export class InstallationValidator extends IInstallationValidator {
this.eventStream.post(new DotnetInstallationValidationError(new Error(message), install, dotnetPath));
throw new EventBasedError('DotnetInstallationValidationError', message);
}
else if(!passedValidation)
if(os.platform() === 'darwin')
{
message = `Did you close the .NET Installer, cancel the installation, or refuse the password prompt? If you want to install the .NET SDK, please try again. If you are facing an error, please report it at https://github.com/dotnet/vscode-dotnet-runtime/issues.
${message}`;
}
if(!passedValidation && !failOnErr)
{
this.eventStream?.post(new DotnetInstallationValidationMissed(new Error(message), message))
}