Try to find the .NET SDK PATH on Mac if it Installs to Unexpected Loc (#1884)
* Try to find the .NET SDK PATH on Mac if it Installs to Unexpected Location Our highest failure for .NET SDK Installs is that the `InstallationValidator` which checks the hard-coded expected path of Installation does not find .NET in the expected location. Unfortunately, nobody has reported this. To get to this point in the code of `Validation`, everything has to have succeeded, including the installer only returning and exiting 0, which it would only do upon installation success. I'm guessing there is some undocumented case where the .NET SDK is installed to a different location, but I couldn't find where. Here is our path check. https://github.com/dotnet/vscode-dotnet-runtime/blob/main/vscode-dotnet-runtime-library/src/Acquisition/WinMacGlobalInstaller.ts#L239 According to the installer source code and our documentation, it should only install to this location or with x64 during emulation. ``` <PkgInstallDirectory>/usr/local/share/dotnet</PkgInstallDirectory> <x64EmulationPkgInstallDirectory>/usr/local/share/dotnet/x64</x64EmulationPkgInstallDirectory> ``` The 64 directory however, is only for when you install a 64-bit SDK on an ARM Mac. We wouldn't expect this to happen because we only install the SDK that matches os.platform(), so we should never install an x64 SDK on an ARM machine. I'm curious to see where this path is and this will also help us track that. It's a bit of a hack, but I think it will have the desired outcome. * Remove extra check for global since this only happens in global code
This commit is contained in:
Родитель
aefdcf3a60
Коммит
22b1065cd5
|
@ -31,6 +31,7 @@ import {
|
|||
SuppressedAcquisitionError,
|
||||
EventBasedError,
|
||||
EventCancellationError,
|
||||
DotnetInstallationValidated,
|
||||
} from '../EventStream/EventStreamEvents';
|
||||
|
||||
import { GlobalInstallerResolver } from './GlobalInstallerResolver';
|
||||
|
@ -60,6 +61,7 @@ import { InstallTrackerSingleton } from './InstallTrackerSingleton';
|
|||
import { DotnetInstallMode } from './DotnetInstallMode';
|
||||
import { IEventStream } from '../EventStream/EventStream';
|
||||
import { IExtensionState } from '../IExtensionState';
|
||||
import { CommandExecutor } from '../Utils/CommandExecutor';
|
||||
import { getInstallIdCustomArchitecture } from '../Utils/InstallIdUtilities';
|
||||
|
||||
/* tslint:disable:no-any */
|
||||
|
@ -405,12 +407,35 @@ ${WinMacGlobalInstaller.InterpretExitCode(installerResult)}`), install);
|
|||
throw err;
|
||||
}
|
||||
|
||||
const installedSDKPath : string = await installer.getExpectedGlobalSDKPath(installingVersion,
|
||||
let installedSDKPath : string = await installer.getExpectedGlobalSDKPath(installingVersion,
|
||||
context.acquisitionContext.architecture ?? this.getDefaultInternalArchitecture(context.acquisitionContext.architecture));
|
||||
|
||||
TelemetryUtilities.setDotnetSDKTelemetryToMatch(context.isExtensionTelemetryInitiallyEnabled, this.extensionContext, context, this.utilityContext);
|
||||
|
||||
context.installationValidator.validateDotnetInstall(install, installedSDKPath, os.platform() !== 'win32');
|
||||
try
|
||||
{
|
||||
context.installationValidator.validateDotnetInstall(install, installedSDKPath, 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));
|
||||
installedSDKPath = result.stdout;
|
||||
}
|
||||
else
|
||||
{
|
||||
error.message += `Which dotnet returned ${result.stdout} and ${result.stderr}.`;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
context.eventStream.post(new DotnetAcquisitionCompleted(install, installedSDKPath, installingVersion));
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import {
|
|||
} from '../EventStream/EventStreamEvents';
|
||||
import { IInstallationValidator } from './IInstallationValidator';
|
||||
import { DotnetInstall } from './DotnetInstall';
|
||||
import { CommandExecutor } from '../Utils/CommandExecutor';
|
||||
|
||||
export class InstallationValidator extends IInstallationValidator {
|
||||
public validateDotnetInstall(install: DotnetInstall, dotnetPath: string, isDotnetFolder = false): void {
|
||||
|
@ -41,7 +42,8 @@ export class InstallationValidator extends IInstallationValidator {
|
|||
}
|
||||
|
||||
private assertOrThrowError(check: boolean, message: string, install: DotnetInstall, dotnetPath: string) {
|
||||
if (!check) {
|
||||
if (!check)
|
||||
{
|
||||
this.eventStream.post(new DotnetInstallationValidationError(new Error(message), install, dotnetPath));
|
||||
throw new EventBasedError('DotnetInstallationValidationError', message);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче