Skip to content
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
23 changes: 23 additions & 0 deletions sample/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
The MIT License (MIT)

Copyright (c) .NET Foundation, Microsoft and Contributors

All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
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.
6 changes: 3 additions & 3 deletions sample/package-lock.json

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

9 changes: 8 additions & 1 deletion sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,21 @@
"version": "0.0.1",
"publisher": "ms-dotnettools",
"engines": {
"vscode": "^1.74.0"
"vscode": "^1.75.0"
},
"categories": [
"Other"
],
"capabilities": {
"virtualWorkspaces": true
},
"extensionDependencies": [

"ms-dotnettools.vscode-dotnet-runtime",

"ms-dotnettools.vscode-dotnet-sdk"

],
"main": "./out/extension.js",
"contributes": {
"commands": [
Expand Down
12 changes: 4 additions & 8 deletions sample/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import * as cp from 'child_process';
import * as path from 'path';
import * as vscode from 'vscode';
import {
Debugging,
IDotnetAcquireContext,
IDotnetAcquireResult,
IDotnetListVersionsResult,
IDotnetVersion,
} from 'vscode-dotnet-runtime-library';
import * as runtimeExtension from 'vscode-dotnet-runtime';
import * as sdkExtension from 'vscode-dotnet-sdk';
//import * as runtimeExtension from 'vscode-dotnet-runtime';
//import * as sdkExtension from 'vscode-dotnet-sdk';

export function activate(context: vscode.ExtensionContext) {

Expand All @@ -37,8 +36,8 @@ export function activate(context: vscode.ExtensionContext) {
*/

const requestingExtensionId = 'ms-dotnettools.sample-extension';
runtimeExtension.activate(context);
sdkExtension.activate(context);
//runtimeExtension.activate(context);
//sdkExtension.activate(context);


// --------------------------------------------------------------------------
Expand Down Expand Up @@ -189,18 +188,15 @@ ${stderr}`);
});
}

Debugging.log(`Sample Global Command Invoked`);

try
{
await vscode.commands.executeCommand('dotnet-sdk.showAcquisitionLog');
let commandContext : IDotnetAcquireContext = { version, requestingExtensionId, installType: 'global' };
Debugging.log(`Calling Acquire Command`);
await vscode.commands.executeCommand('dotnet-sdk.acquire', commandContext);
}
catch (error)
{
Debugging.log(`An error occured in the execution of the command, see the error: ${(error as Error).toString()}`);
vscode.window.showErrorMessage((error as Error).toString());
}
});
Expand Down
2 changes: 1 addition & 1 deletion sample/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@types/node" "*"

"@types/vscode@1.74.0":
"integrity" "sha1-tNbRktWut16R0K3vaJw+zvmHnac="
"integrity" "sha1-StwhtOf1J7iT3jQYwhqR8eUDvc0="
"resolved" "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@types/vscode/-/vscode-1.74.0.tgz"
"version" "1.74.0"

Expand Down
4 changes: 2 additions & 2 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.

2 changes: 1 addition & 1 deletion vscode-dotnet-runtime-extension/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
"@types/node" "*"

"@types/vscode@1.74.0":
"integrity" "sha1-tNbRktWut16R0K3vaJw+zvmHnac="
"integrity" "sha1-StwhtOf1J7iT3jQYwhqR8eUDvc0="
"resolved" "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@types/vscode/-/vscode-1.74.0.tgz"
"version" "1.74.0"

Expand Down
32 changes: 16 additions & 16 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 @@ -267,7 +267,7 @@ export class DotnetCoreAcquisitionWorker implements IDotnetCoreAcquisitionWorker
const installedSDKPath : string = await installer.getExpectedGlobalSDKPath(await globalInstallerResolver.getFullVersion(), os.arch());

Debugging.log(`Validating Dotnet Install.`, this.context.eventStream);
this.context.installationValidator.validateDotnetInstall(installingVersion, installedSDKPath);
this.context.installationValidator.validateDotnetInstall(installingVersion, installedSDKPath, true);

this.context.eventStream.post(new DotnetAcquisitionCompleted(installingVersion, installedSDKPath));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export class GlobalInstallerResolver {
*/
private getIndexUrl(majorMinor : string ) : string
{
return `https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/'${majorMinor}'/releases.json`;
return `https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/${majorMinor}/releases.json`;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ import { IEventStream } from '../EventStream/EventStream';
export abstract class IInstallationValidator {
constructor(protected readonly eventStream: IEventStream) {}

public abstract validateDotnetInstall(version: string, dotnetPath: string): void;
public abstract validateDotnetInstall(version: string, dotnetPath: string, isDotnetFolder? : boolean): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,29 @@ import {
import { IInstallationValidator } from './IInstallationValidator';

export class InstallationValidator extends IInstallationValidator {
public validateDotnetInstall(version: string, dotnetPath: string): void {
public validateDotnetInstall(version: string, dotnetPath: string, isDotnetFolder = false): void {
const dotnetValidationFailed = `Validation of .dotnet installation for version ${version} failed:`;
const folder = path.dirname(dotnetPath);

this.assertOrThrowError(fs.existsSync(folder),
if(!isDotnetFolder)
{
this.assertOrThrowError(fs.existsSync(folder),
`${dotnetValidationFailed} Expected installation folder ${folder} does not exist.`, version, dotnetPath);

this.assertOrThrowError(fs.existsSync(dotnetPath),
`${dotnetValidationFailed} Expected executable does not exist at "${dotnetPath}"`, version, dotnetPath);
this.assertOrThrowError(fs.existsSync(dotnetPath),
`${dotnetValidationFailed} Expected executable does not exist at "${dotnetPath}"`, version, dotnetPath);

this.assertOrThrowError(fs.lstatSync(dotnetPath).isFile(),
`${dotnetValidationFailed} Expected executable file exists but is not a file: "${dotnetPath}"`, version, dotnetPath);
this.assertOrThrowError(fs.lstatSync(dotnetPath).isFile(),
`${dotnetValidationFailed} Expected executable file exists but is not a file: "${dotnetPath}"`, version, dotnetPath);
}
else
{
this.assertOrThrowError(fs.existsSync(folder),
`${dotnetValidationFailed} Expected dotnet folder ${dotnetPath} does not exist.`, version, dotnetPath);

this.assertOrThrowError(fs.readdirSync(folder).length !== 0,
`${dotnetValidationFailed} The dotnet folder is empty "${dotnetPath}"`, version, dotnetPath);
}

this.eventStream.post(new DotnetInstallationValidated(version));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,10 @@ export class WinMacGlobalInstaller extends IGlobalInstaller {
{
if(os.platform() === 'win32')
{
if(installedArch === 'ia32')
{
// The program files should always be set, but in the off chance they are wiped, we can try to use the default as backup.
return path.resolve(process.env['programfiles(x86)'] ?? `C:\\Program Files (x86)\\dotnet\\sdk\\`);
}
else if(installedArch === 'x64')
{
return path.resolve(process.env.programfiles ?? `C:\\Program Files\\dotnet\\sdk\\`);
}
// The program files should always be set, but in the off chance they are wiped, we can try to use the default as backup.
// Both ia32 and x64 machines will use 'Program Files'
// We don't anticipate a user would need to install the x86 SDK, and we dont have any routes that support that yet.
return path.resolve(path.join(process.env.programfiles!, 'dotnet', 'sdk') ?? `C:\\Program Files\\dotnet\\sdk\\`);
}
else if(os.platform() === 'darwin')
{
Expand Down Expand Up @@ -282,17 +277,18 @@ export class WinMacGlobalInstaller extends IGlobalInstaller {

if (os.platform() === 'win32')
{
const sdkInstallRecords64Bit = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\dotnet\\Setup\\InstalledVersions\\x64\\sdk';
const sdkInstallRecords64Bit = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\dotnet\\Setup\\InstalledVersions\\x64\\sdk';
const sdkInstallRecords32Bit = sdkInstallRecords64Bit.replace('x64', 'x86');

const queries = [sdkInstallRecords32Bit, sdkInstallRecords64Bit];
for ( const query of queries)
{
try
{
const registryQueryCommand = `%SystemRoot%\\System32\\reg.exe`;
// stdio settings: don't print registry key DNE warnings as they may not be on the machine if no SDKs are installed and we dont want to error.
const installRecordKeysOfXBit = (await this.commandRunner.execute(`${registryQueryCommand} query "${query}"`, {stdio : ['pipe', 'ignore', 'ignore']}))[0];
const registryQueryCommand = path.join(`${process.env.SystemRoot}`, `System32\\reg.exe`);
// /reg:32 is added because all keys on 64 bit machines are all put into the WOW node. They won't be on the WOW node on a 32 bit machine.
const fullQuery = `${registryQueryCommand} query ${query} \/reg:32`;
const installRecordKeysOfXBit = (await this.commandRunner.execute(fullQuery))[0];
const installedSdks = this.extractVersionsOutOfRegistryKeyStrings(installRecordKeysOfXBit);
// Append any newly found sdk versions
sdks = sdks.concat(installedSdks.filter((item) => sdks.indexOf(item) < 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
DotnetAcquisitionError,
DotnetAcquisitionStarted,
DotnetAcquisitionVersionError,
DotnetDebuggingMessage,
DotnetExistingPathResolutionCompleted,
} from './EventStreamEvents';
import { EventType } from './EventType';
Expand All @@ -22,8 +23,10 @@ export class OutputChannelObserver implements IEventStreamObserver {
constructor(private readonly outputChannel: vscode.OutputChannel) {
}

public post(event: IEvent): void {
switch (event.type) {
public post(event: IEvent): void
{
switch (event.type)
{
case EventType.DotnetRuntimeAcquisitionStart:
this.outputChannel.append('Downloading the .NET Runtime.');
this.outputChannel.appendLine('');
Expand Down Expand Up @@ -88,6 +91,10 @@ export class OutputChannelObserver implements IEventStreamObserver {
this.stopDownloadIndicator();
}
break;
case EventType.DotnetDebuggingMessage:
const loggedMessage = event as DotnetDebuggingMessage;
this.outputChannel.appendLine(loggedMessage.message);
break;
}
}

Expand Down
Loading