* fix emu

* improve mac path check

* Account for when SDK is not installed under emulation but node js is
This commit is contained in:
Noah Gilson 2024-09-17 09:33:34 -07:00 коммит произвёл GitHub
Родитель 0b37e6610a
Коммит 82b6a041fe
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 15 добавлений и 4 удалений

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

@ -208,8 +208,9 @@ This report should be made at https://github.com/dotnet/vscode-dotnet-runtime/is
}
else
{
const command = CommandExecutor.makeCommand(`rm`, [`-rf`, `${path.join(path.dirname(this.getMacPath()), 'sdk', install.version)}`, `&&`,
`rm`, `-rf`, `${path.join(path.dirname(this.getMacPath()), 'sdk-manifests', install.version)}`], true);
const macPath = await this.getMacPath();
const command = CommandExecutor.makeCommand(`rm`, [`-rf`, `${path.join(path.dirname(macPath), 'sdk', install.version)}`, `&&`,
`rm`, `-rf`, `${path.join(path.dirname(macPath), 'sdk-manifests', install.version)}`], true);
const commandResult = await this.commandRunner.execute(command, {timeout : this.acquisitionContext.timeoutSeconds * 1000});
this.handleTimeout(commandResult);
@ -330,7 +331,8 @@ Permissions: ${JSON.stringify(await this.commandRunner.execute(CommandExecutor.m
}
else if(os.platform() === 'darwin')
{
return this.getMacPath(macPathShouldExist);
const sdkPath = await this.getMacPath(macPathShouldExist);
return sdkPath;
}
const err = new DotnetUnexpectedInstallerOSError(new EventBasedError('DotnetUnexpectedInstallerOSError',
@ -352,10 +354,19 @@ If you were waiting for the install to succeed, please extend the timeout settin
}
}
private getMacPath(macPathShouldExist = true) : string
private async getMacPath(macPathShouldExist = true) : Promise<string>
{
const standardHostPath = path.resolve(`/usr/local/share/dotnet/dotnet`);
const arm64EmulationHostPath = path.resolve(`/usr/local/share/dotnet/x64/dotnet`);
const findTrueArchCommand = CommandExecutor.makeCommand(`uname`, [`-p`]);
if((os.arch() === 'x64' || os.arch() === 'ia32') && (await this.commandRunner.execute(findTrueArchCommand, null, false)).stdout.toLowerCase().includes('arm') && (fs.existsSync(arm64EmulationHostPath) || !macPathShouldExist))
{
// VS Code runs on an emulated version of node which will return x64 or use x86 emulation for ARM devices.
// os.arch() returns the architecture of the node binary, not the system architecture, so it will not report arm on an arm device.
return arm64EmulationHostPath;
}
if(!macPathShouldExist || fs.existsSync(standardHostPath) || !fs.existsSync(arm64EmulationHostPath))
{
return standardHostPath;