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

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

Merged
merged 4 commits into from
Oct 16, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* The .NET Foundation licenses this file to you under the MIT license.
*--------------------------------------------------------------------------------------------*/

import { IDotnetAcquireContext, IVSCodeExtensionContext } from '..';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer needed, thank you, I will remove this in a upcoming change

import { IEventStream } from '../EventStream/EventStream';
import { DotnetInstall } from './DotnetInstall';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as fs from 'fs';
import * as path from 'path';
import * as os from 'os';
import {
DotnetInstallationValidated,
DotnetInstallationValidationError,
Expand Down Expand Up @@ -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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dne?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not exist

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should be more clear with these messages, good point

}
}

this.eventStream.post(new DotnetInstallationValidated(install));
Expand All @@ -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))
}
Expand Down