Skip to content
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
8 changes: 8 additions & 0 deletions THIRD-PARTY-NOTICES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,14 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

-------------------------------

License notice for shelljs, minimatch, js-yaml
https://github.com/jslicense/BlueOak-1.0.0/blob/main/BlueOak-1.0.0.md

-------------------------------

https://blueoakcouncil.org/license/1.0.0

-------------------------------

Expand Down
42 changes: 21 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions vscode-dotnet-runtime-extension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion vscode-dotnet-runtime-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ export function activate(vsCodeContext: vscode.ExtensionContext, extensionContex

globalEventStream.post(new DotnetAcquisitionRequested(commandContext.version, commandContext.requestingExtensionId ?? 'notProvided', commandContext.mode!, commandContext.installType ?? 'global'));

const existingOfflinePath = await getExistingInstallOffline(worker, workerContext);
const existingOfflinePath = await getExistingInstallIfOffline(worker, workerContext);
if (existingOfflinePath)
{
return Promise.resolve(existingOfflinePath);
Expand Down Expand Up @@ -449,6 +449,8 @@ export function activate(vsCodeContext: vscode.ExtensionContext, extensionContex

globalEventStream.post(new DotnetAcquisitionStatusRequested(commandContext.version, commandContext.requestingExtensionId));

// Caveat : acquireStatus expects only a major.minor, so fully specified versions won't be checked here

const existingOfflinePath = await getExistingInstallOffline(worker, workerContext);
if (existingOfflinePath)
{
Expand Down Expand Up @@ -962,6 +964,16 @@ ${JSON.stringify(commandContext)}`));
};
}

async function getExistingInstallIfOffline(worker: DotnetCoreAcquisitionWorker, workerContext: IAcquisitionWorkerContext): Promise<IDotnetAcquireResult | null>
{
const isOffline = !(await WebRequestWorkerSingleton.getInstance().isOnline(timeoutValue ?? defaultTimeoutValue, globalEventStream));
if (isOffline)
{
return getExistingInstallOffline(worker, workerContext);
}
return null;
}

async function getExistingInstallOffline(worker: DotnetCoreAcquisitionWorker, workerContext: IAcquisitionWorkerContext): Promise<IDotnetAcquireResult | null>
{
workerContext.acquisitionContext.architecture ??= DotnetCoreAcquisitionWorker.defaultArchitecture();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,23 +490,16 @@ suite('DotnetCoreAcquisitionExtension End to End', function ()
}
}).timeout(standardTimeoutTime);

test('Install SDK Globally E2E (Requires Admin)', async () =>
async function runGlobalSdkInstallTest(version: string)
{
// We only test if the process is running under ADMIN because non-admin requires user-intervention.
const sdkVersion = '7.0.103';
const context: IDotnetAcquireContext = { version: sdkVersion, requestingExtensionId: 'sample-extension', installType: 'global' };
const context: IDotnetAcquireContext = { version, requestingExtensionId: 'sample-extension', installType: 'global' };
if (await new FileUtilities().isElevated(getMockAcquisitionWorkerContext(context), getMockUtilityContext()))
{
const originalPath = process.env.PATH;

// We cannot use the describe pattern to restore the environment variables using vscode's extension testing infrastructure.
// So we must set and unset it ourselves, which isn't ideal as this variable could remain.
let result: IDotnetAcquireResult;
let result: IDotnetAcquireResult | undefined;
let error: any;
let pathAfterInstall;
let pathAfterInstall: string | undefined;

// We cannot test much as we don't want to leave global installs on dev boxes. But we do want to make sure the e-2-e goes through the right path. Vendors can test the rest.
// So we have this environment variable that tells us to stop before running any real install.
process.env.VSCODE_DOTNET_GLOBAL_INSTALL_FAKE_PATH = 'true';
try
{
Expand All @@ -521,25 +514,43 @@ suite('DotnetCoreAcquisitionExtension End to End', function ()
pathAfterInstall = process.env.PATH;
process.env.VSCODE_DOTNET_GLOBAL_INSTALL_FAKE_PATH = undefined;
process.env.PATH = originalPath;
}

if (error)
{
throw (new Error(`The test failed to run the acquire command successfully. Error: ${error}`));
}
if (error)
{
throw new Error(`The test failed to run the acquire command successfully for version ${version}. Error: ${error}`);
}

assert.exists(result!, 'The global acquisition command did not provide a result?');
assert.exists(result, `The global acquisition command did not provide a result for version ${version}`);
assert.exists(result!.dotnetPath);
assert.equal(result!.dotnetPath, 'fake-sdk');
assert.exists(pathAfterInstall, 'The environment variable PATH for DOTNET was not found?');
assert.include(pathAfterInstall, result!.dotnetPath, 'Is the PATH correctly set by the global installer?');
assert.include(pathAfterInstall!, result!.dotnetPath, 'Is the PATH correctly set by the global installer?');
}
else
{
// We could run the installer without privilege but it would require human interaction to use the UAC
// And we wouldn't be able to kill the process so the test would leave a lot of hanging processes on the machine
warn('The Global SDK E2E Install test cannot run as the machine is unprivileged.');
}
}

test('Install SDK Globally E2E (Requires Admin)', async () =>
{
await runGlobalSdkInstallTest('7.0.103');
}).timeout(standardTimeoutTime * 1000);

test('Install SDK Globally with major version format', async () =>
{
await runGlobalSdkInstallTest('9');
}).timeout(standardTimeoutTime * 1000);

test('Install SDK Globally with major minor format', async () =>
{
await runGlobalSdkInstallTest('10.0');
}).timeout(standardTimeoutTime * 1000);

test('Install SDK Globally with feature band format', async () =>
{
await runGlobalSdkInstallTest('10.0.1xx');
}).timeout(standardTimeoutTime * 1000);

test('Telemetry Sent During Install and Uninstall', async () =>
Expand Down Expand Up @@ -778,7 +789,7 @@ Paths: 'acquire returned: ${resultForAcquiringPathSettingRuntime.dotnetPath} whi
assert.exists(result);
assert.exists(result!.dotnetPath);
assert.isTrue(fs.existsSync(result!.dotnetPath!));
await promisify(rimraf)(result!.dotnetPath!);
await fs.promises.rm(result!.dotnetPath!, { force: true });
}

test('Install Runtime Status Command', async () =>
Expand Down
12 changes: 6 additions & 6 deletions vscode-dotnet-runtime-extension/yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions vscode-dotnet-runtime-library/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,22 @@ export function getMajorMinorFromValidVersion(fullySpecifiedVersion: string)

/**
*
* @param fullySpecifiedVersion the fully specified version, e.g. 7.0.301 to get the major minor from.
* @param fullySpecifiedVersion the fully specified version, e.g. 7.0.301 to get the major minor from. Also accepts '8' and will assume a .0 minor.
* @returns the major.minor in the form of '3.1', etc.
*/
export function getMajorMinor(fullySpecifiedVersion: string, eventStream: IEventStream, context: IAcquisitionWorkerContext): string
{
if (fullySpecifiedVersion.split('.').length < 2)
{
if (fullySpecifiedVersion.split('.').length === 0 && isNumber(fullySpecifiedVersion))
{
return `${fullySpecifiedVersion}.0`;
}
else if (fullySpecifiedVersion.split('.').length === 1 && isNumber(fullySpecifiedVersion.split('.')[0]))
{
return fullySpecifiedVersion;
}

const event = new DotnetVersionResolutionError(new EventCancellationError('DotnetVersionResolutionError',
`The requested version ${fullySpecifiedVersion} is invalid.`),
getInstallFromContext(context));
Expand Down
Loading