Skip to content

Get global install on mac to work #3

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

Draft
wants to merge 2 commits into
base: nagilson-admin-install
Choose a base branch
from
Draft
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
1,630 changes: 817 additions & 813 deletions sample/yarn.lock

Large diffs are not rendered by default.

4,483 changes: 2,244 additions & 2,239 deletions vscode-dotnet-runtime-extension/yarn.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as path from 'path';
import rimraf = require('rimraf');
import * as proc from 'child_process';
import * as https from 'https';
import * as vscode from 'vscode';

import {
DotnetAcquisitionAlreadyInstalled,
Expand Down Expand Up @@ -120,15 +121,16 @@ export class DotnetCoreAcquisitionWorker implements IDotnetCoreAcquisitionWorker
* @returns the dotnet acqusition result.
*/
private async acquire(version: string, installRuntime: boolean, globalInstallerResolver : GlobalSDKInstallerResolver | null = null): Promise<IDotnetAcquireResult> {
const existingAcquisitionPromise = this.acquisitionPromises[version];
/*const existingAcquisitionPromise = this.acquisitionPromises[version];
if (existingAcquisitionPromise)
{
// This version of dotnet is already being acquired. Memoize the promise.
this.context.eventStream.post(new DotnetAcquisitionInProgress(version));
return existingAcquisitionPromise.then((res) => ({ dotnetPath: res }));
}
else
{
*/ // todo uncomment this as it needs to be done to debug in mac if it hangs
//else
//{
// We're the only one acquiring this version of dotnet, start the acquisition process.
let acquisitionPromise = null;
if(globalInstallerResolver !== null)
Expand All @@ -149,7 +151,7 @@ export class DotnetCoreAcquisitionWorker implements IDotnetCoreAcquisitionWorker

this.acquisitionPromises[version] = acquisitionPromise;
return acquisitionPromise.then((res) => ({ dotnetPath: res }));
}
//}
}

/**
Expand Down Expand Up @@ -365,8 +367,8 @@ export class DotnetCoreAcquisitionWorker implements IDotnetCoreAcquisitionWorker
{
if(os.platform() !== 'win32')
{
// TODO: Implemnet root check on linux
return false;
const commandResult = proc.spawnSync("id", ["-u"]);
return commandResult.status === 0;
}

try
Expand Down Expand Up @@ -394,6 +396,18 @@ export class DotnetCoreAcquisitionWorker implements IDotnetCoreAcquisitionWorker
return path.join(`C:\\Program Files\\dotnet\\sdk\\`, specificSDKVersionInstalled);
}
}
else if(os.platform() === 'darwin')
{
if(installedArch !== 'x64')
{
return path.join(`/usr/local/share/dotnet/sdk`, specificSDKVersionInstalled);
}
else
{
// We only know this to be correct in the ARM scenarios but I decided to assume the default is the same elsewhere.
return path.join(`/usr/local/share/dotnet/x64/dotnet/sdk`, specificSDKVersionInstalled);
}
}

// TODO check this on mac and linux it should be root. and check security of returning this
return '';
Expand Down Expand Up @@ -434,6 +448,24 @@ export class DotnetCoreAcquisitionWorker implements IDotnetCoreAcquisitionWorker
{
// TODO: Handle this differently depending on the package type.
let installCommand = `${path.resolve(installerPath)}`;
let sudoPassword : string | undefined = '';

if(os.platform() === 'darwin')
{
// For Mac:
// We need to run the .NET SDK installer under sudo, otherwise it will return success without doing anything.
// We also get a .pkg file which we cannot just run, we must forward it to the OSX installer utility.
// The Mac installer utility does not allow you to pass arguments in to the pkg under execution, so we cannot rely on the flags passed to the installer here.

// To run a command under sudo, we need to prompt the user for their password.
// We MUST make sure that this does NOT get echo'd out anywhere.

// The sudo command is wrapped in a sh to allow us to forward the sudo arguments correctly.
// The command for sudo to run is wrapped in bash to allow the arguments to the installer command to flow correctly.
installCommand = `open`
const commandResult = proc.spawnSync('open', ['-W', `${path.resolve(installerPath)}`]);
return commandResult.toString();
}

try
{
Expand Down
Loading