Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f316b8a
Get signature check from online shas working
nagilson Aug 16, 2023
701833d
Make installer file read only so it cant be swapped
nagilson Aug 16, 2023
1592def
Learn how to attach function to on did change telemetry enabled event
nagilson Aug 18, 2023
2f41e11
[wip] telemetry code
nagilson Aug 18, 2023
38becc9
Merge remote-tracking branch 'origin/nagilson-global-sdk-install' int…
nagilson Oct 12, 2023
cd14f06
Complete merging with the modified global pr
nagilson Oct 12, 2023
cdca38b
Fix Adding Microsoft Feed
nagilson Oct 17, 2023
28a8c02
Remove Read Only CHMOD as its not needed
nagilson Oct 17, 2023
4910361
[WIP] Telemetry set on SDK to match VS Code
nagilson Oct 17, 2023
919442f
Merge branch 'nagilson-global-compliance' of https://github.com/nagil…
nagilson Oct 17, 2023
8e06ab0
Add Warning if we fail to disable SDK Telemetry
nagilson Oct 18, 2023
1a83c40
Add the change to ubuntu 20.04 to use sudo
nagilson Oct 18, 2023
72f60df
Fix timeout issue & Set environment correctly on windows
nagilson Oct 19, 2023
0436695
Shell is also needed to execute environment edits on osx and linux
nagilson Oct 19, 2023
76900c1
Explicitly add vscode module to the package json
nagilson Oct 20, 2023
8b95085
Only export the variable for osx to simplify command
nagilson Oct 20, 2023
8ca1e1c
Revert "Explicitly add vscode module to the package json"
nagilson Oct 20, 2023
2b26c39
Remove linux and osx auto telemetry setting
nagilson Oct 20, 2023
d2c9a6f
Update node on build machine so they hopefully work correctly
nagilson Oct 20, 2023
1d0ed45
fix linting issue
nagilson Oct 20, 2023
95d9e21
Update vscode to match pipeline version
nagilson Oct 20, 2023
465256b
update shas from the npm upstream, as they have changed for the new v…
nagilson Oct 20, 2023
04d189b
Update inherited vscode types to include new properties
nagilson Oct 20, 2023
f4331b8
Set the environment of the VS Code Terminal
nagilson Oct 20, 2023
144b9b1
Fix build by isolating vscode references
nagilson Oct 24, 2023
bfdad8d
Fix Linting Concerns
nagilson Oct 24, 2023
e637a2b
Revert "Update inherited vscode types to include new properties"
nagilson Oct 24, 2023
5d5b3ab
Revert "update shas from the npm upstream, as they have changed for t…
nagilson Oct 24, 2023
bf52539
Revert "Update vscode to match pipeline version"
nagilson Oct 24, 2023
fadbf6a
Revert "Update node on build machine so they hopefully work correctly"
nagilson Oct 24, 2023
853beee
Remove unused imports and trailing commas
nagilson Oct 24, 2023
2d63950
remove duplicated semicolon
nagilson Oct 24, 2023
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
2 changes: 1 addition & 1 deletion vscode-dotnet-runtime-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"dotnetAcquisitionExtension.enableTelemetry": {
"type": "boolean",
"default": true,
"description": "Enable Telemetry for the .NET Runtime Install Tool"
"description": "Enable Telemetry for the .NET Runtime Install Tool. Restart VS Code to apply changes."
},
"dotnetAcquisitionExtension.installTimeoutValue": {
"type": "number",
Expand Down
27 changes: 19 additions & 8 deletions vscode-dotnet-runtime-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import {
registerEventStream,
RuntimeInstallationDirectoryProvider,
VersionResolver,
VSCodeExtensionContext,
VSCodeEnvironment,
WindowDisplayWorker,
} from 'vscode-dotnet-runtime-library';
import { dotnetCoreAcquisitionExtensionId } from './DotnetCoreAcquisitionId';
Expand Down Expand Up @@ -70,18 +72,25 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
extensionContext.extensionConfiguration :
vscode.workspace.getConfiguration(configPrefix);

const extensionTelemetryEnabled = enableExtensionTelemetry(extensionConfiguration, configKeys.enableTelemetry);
const displayWorker = extensionContext ? extensionContext.displayWorker : new WindowDisplayWorker();

const utilContext = {
ui : displayWorker,
vsCodeEnv: new VSCodeEnvironment()
}

const eventStreamContext = {
displayChannelName,
logPath: context.logPath,
extensionId: dotnetCoreAcquisitionExtensionId,
enableTelemetry: enableExtensionTelemetry(extensionConfiguration, configKeys.enableTelemetry),
enableTelemetry: extensionTelemetryEnabled,
telemetryReporter: extensionContext ? extensionContext.telemetryReporter : undefined,
showLogCommand: `${commandPrefix}.${commandKeys.showAcquisitionLog}`,
packageJson,
packageJson
} as IEventStreamContext;
const [eventStream, outputChannel, loggingObserver, eventStreamObservers] = registerEventStream(eventStreamContext);
const [eventStream, outputChannel, loggingObserver, eventStreamObservers] = registerEventStream(eventStreamContext, new VSCodeExtensionContext(context), utilContext);

const displayWorker = extensionContext ? extensionContext.displayWorker : new WindowDisplayWorker();
const extensionConfigWorker = new ExtensionConfigurationWorker(extensionConfiguration, configKeys.existingPath);
const issueContext = (errorConfiguration: ErrorConfiguration | undefined, commandName: string, version?: string) => {
return {
Expand All @@ -93,7 +102,7 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
commandName,
version,
moreInfoUrl,
timeoutInfoUrl: `${moreInfoUrl}#install-script-timeouts`,
timeoutInfoUrl: `${moreInfoUrl}#install-script-timeouts`
} as IIssueContext;
};
const timeoutValue = extensionConfiguration.get<number>(configKeys.installTimeoutValue);
Expand All @@ -108,12 +117,13 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
storagePath: context.globalStoragePath,
extensionState: context.globalState,
eventStream,
acquisitionInvoker: new AcquisitionInvoker(context.globalState, eventStream, resolvedTimeoutSeconds),
acquisitionInvoker: new AcquisitionInvoker(context.globalState, eventStream, resolvedTimeoutSeconds, utilContext),
installationValidator: new InstallationValidator(eventStream),
timeoutValue: resolvedTimeoutSeconds,
installDirectoryProvider: new RuntimeInstallationDirectoryProvider(context.globalStoragePath),
proxyUrl: proxyLink
});
proxyUrl: proxyLink,
isExtensionTelemetryInitiallyEnabled: extensionTelemetryEnabled
}, utilContext, new VSCodeExtensionContext(context));
const existingPathResolver = new ExistingPathResolver();
const versionResolver = new VersionResolver(context.globalState, eventStream, resolvedTimeoutSeconds, proxyLink);

Expand Down Expand Up @@ -197,4 +207,5 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
ensureDependenciesRegistration,
reportIssueRegistration,
...eventStreamObservers);

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ import {
MockExtensionConfiguration,
MockExtensionContext,
MockTelemetryReporter,
MockWindowDisplayWorker,
MockWindowDisplayWorker
} from 'vscode-dotnet-runtime-library';
import * as extension from '../../extension';
/* tslint:disable:no-any */
const assert : any = chai.assert;
const standardTimeoutTime = 40000;

suite('DotnetCoreAcquisitionExtension End to End', function() {
this.retries(3);
Expand Down Expand Up @@ -59,7 +60,7 @@ suite('DotnetCoreAcquisitionExtension End to End', function() {
// Commands should now be registered
assert.exists(extensionContext);
assert.isAbove(extensionContext.subscriptions.length, 0);
});
}).timeout(standardTimeoutTime);

test('Install Command', async () => {
const context: IDotnetAcquireContext = { version: '2.2', requestingExtensionId };
Expand All @@ -69,7 +70,7 @@ suite('DotnetCoreAcquisitionExtension End to End', function() {
assert.isTrue(fs.existsSync(result!.dotnetPath));
assert.include(result!.dotnetPath, '.dotnet');
assert.include(result!.dotnetPath, context.version);
}).timeout(40000);
}).timeout(standardTimeoutTime);

test('Uninstall Command', async () => {
const context: IDotnetAcquireContext = { version: '2.1', requestingExtensionId };
Expand All @@ -80,7 +81,7 @@ suite('DotnetCoreAcquisitionExtension End to End', function() {
assert.include(result!.dotnetPath, context.version);
await vscode.commands.executeCommand<string>('dotnet.uninstallAll', context.version);
assert.isFalse(fs.existsSync(result!.dotnetPath));
}).timeout(40000);
}).timeout(standardTimeoutTime);


test('Install and Uninstall Multiple Versions', async () => {
Expand All @@ -99,7 +100,7 @@ suite('DotnetCoreAcquisitionExtension End to End', function() {
for (const dotnetPath of dotnetPaths) {
assert.isTrue(fs.existsSync(dotnetPath));
}
}).timeout(60000);
}).timeout(standardTimeoutTime * 2);

test('Telemetry Sent During Install and Uninstall', async () => {
const rntVersion = '2.2';
Expand Down Expand Up @@ -137,7 +138,7 @@ suite('DotnetCoreAcquisitionExtension End to End', function() {
// Check that no errors were reported
const errors = MockTelemetryReporter.telemetryEvents.filter((event: ITelemetryEvent) => event.eventName.includes('Error'));
assert.isEmpty(errors, 'No error events were reported in telemetry reporting');
}).timeout(40000);
}).timeout(standardTimeoutTime);

test('Telemetry Sent on Error', async () => {
const context: IDotnetAcquireContext = { version: 'foo', requestingExtensionId };
Expand All @@ -148,7 +149,7 @@ suite('DotnetCoreAcquisitionExtension End to End', function() {
const versionError = MockTelemetryReporter.telemetryEvents.find((event: ITelemetryEvent) => event.eventName === '[ERROR]:DotnetVersionResolutionError');
assert.exists(versionError, 'The version resolution error appears in telemetry');
}
}).timeout(2000);
}).timeout(standardTimeoutTime/2);

test('Install Command Passes With Warning With No RequestingExtensionId', async () => {
const context: IDotnetAcquireContext = { version: '3.1' };
Expand All @@ -157,15 +158,15 @@ suite('DotnetCoreAcquisitionExtension End to End', function() {
assert.exists(result!.dotnetPath);
assert.include(result!.dotnetPath, context.version);
assert.include(mockDisplayWorker.warningMessage, 'Ignoring existing .NET paths');
}).timeout(40000);
}).timeout(standardTimeoutTime);

test('Install Command With Path Config Defined', async () => {
const context: IDotnetAcquireContext = { version: '0.1', requestingExtensionId: 'alternative.extension' };
const result = await vscode.commands.executeCommand<IDotnetAcquireResult>('dotnet.acquire', context);
assert.exists(result);
assert.exists(result!.dotnetPath);
assert.equal(result!.dotnetPath, 'foo');
});
}).timeout(standardTimeoutTime);

test('Install Runtime Status Command', async () => {
// Runtime is not yet installed
Expand All @@ -185,5 +186,5 @@ suite('DotnetCoreAcquisitionExtension End to End', function() {
assert.exists(result!.dotnetPath);
assert.isTrue(fs.existsSync(result!.dotnetPath!));
rimraf.sync(result!.dotnetPath!);
}).timeout(40000);
}).timeout(standardTimeoutTime);
});
12 changes: 6 additions & 6 deletions vscode-dotnet-runtime-library/distro-data/distro-support.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
}
],
"preInstallCommands": [
"apt-get update && apt install -y wget",
"wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb",
"sudo dpkg -i packages-microsoft-prod.deb && rm packages-microsoft-prod.deb"
"sudo apt-get update && sudo apt install -y wget",
"sudo wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb",
"sudo dpkg -i packages-microsoft-prod.deb"
]
},
{
Expand All @@ -49,9 +49,9 @@
}
],
"preInstallCommands": [
"apt-get update && apt install -y wget",
"wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb",
"sudo dpkg -i packages-microsoft-prod.deb && rm packages-microsoft-prod.deb"
"sudo apt-get update && sudo apt install -y wget",
"sudo wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb",
"sudo dpkg -i packages-microsoft-prod.deb"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,19 @@ import { TelemetryUtilities } from '../EventStream/TelemetryUtilities';
import { DotnetCoreAcquisitionWorker } from './DotnetCoreAcquisitionWorker';
import { FileUtilities } from '../Utils/FileUtilities';
import { CommandExecutor } from '../Utils/CommandExecutor';
import { IUtilityContext } from '../Utils/IUtilityContext';

export class AcquisitionInvoker extends IAcquisitionInvoker {
protected readonly scriptWorker: IInstallScriptAcquisitionWorker;
protected fileUtilities : FileUtilities;
protected utilityContext : IUtilityContext;
private noPowershellError = `powershell.exe is not discoverable on your system. Is PowerShell added to your PATH and correctly installed? Please visit: https://learn.microsoft.com/powershell/scripting/install/installing-powershell-on-windows.
You will need to restart VS Code after these changes. If PowerShell is still not discoverable, try setting a custom existingDotnetPath following our instructions here: https://github.com/dotnet/vscode-dotnet-runtime/blob/main/Documentation/troubleshooting-runtime.md.`

constructor(extensionState: IExtensionState, eventStream: IEventStream, timeoutTime : number) {
constructor(extensionState: IExtensionState, eventStream: IEventStream, timeoutTime : number, utilContext : IUtilityContext) {

super(eventStream);
this.utilityContext = utilContext;
this.scriptWorker = new InstallScriptAcquisitionWorker(extensionState, eventStream, timeoutTime);
this.fileUtilities = new FileUtilities();
}
Expand Down Expand Up @@ -139,7 +142,7 @@ You will need to restart VS Code after these changes. If PowerShell is still not
try
{
// Check if PowerShell exists and is on the path.
const commandWorking = await new CommandExecutor(this.eventStream).TryFindWorkingCommand([`powershell.exe`,
const commandWorking = await new CommandExecutor(this.eventStream, this.utilityContext).TryFindWorkingCommand([`powershell.exe`,
`%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`, `pwsh`, `powershell`, `pwsh.exe`]);
if(!commandWorking[1])
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
DotnetAcquisitionStatusResolved,
DotnetAcquisitionStatusUndefined,
DotnetNonZeroInstallerExitCodeError,
DotnetCustomMessageEvent,
DotnetInstallGraveyardEvent,
DotnetInstallKeyCreatedEvent,
DotnetLegacyInstallDetectedEvent,
Expand All @@ -32,7 +31,7 @@ import {
DotnetBeginGlobalInstallerExecution,
DotnetCompletedGlobalInstallerExecution,
DotnetFakeSDKEnvironmentVariableTriggered,
SuppressedAcquisitionError,
SuppressedAcquisitionError
} from '../EventStream/EventStreamEvents';
import { IDotnetAcquireResult } from '../IDotnetAcquireResult';
import { IAcquisitionWorkerContext } from './IAcquisitionWorkerContext';
Expand All @@ -43,7 +42,9 @@ import { WinMacGlobalInstaller } from './WinMacGlobalInstaller';
import { IGlobalInstaller } from './IGlobalInstaller';
import { LinuxGlobalInstaller } from './LinuxGlobalInstaller';
import { Debugging } from '../Utils/Debugging';
import { IDotnetAcquireContext } from '..';
import { IDotnetAcquireContext, IVSCodeExtensionContext } from '..';
import { IUtilityContext } from '../Utils/IUtilityContext';
import { TelemetryUtilities } from '../EventStream/TelemetryUtilities';
/* tslint:disable:no-any */

export class DotnetCoreAcquisitionWorker implements IDotnetCoreAcquisitionWorker {
Expand All @@ -58,16 +59,17 @@ export class DotnetCoreAcquisitionWorker implements IDotnetCoreAcquisitionWorker
private globalResolver: GlobalInstallerResolver | null;

private acquisitionPromises: { [installKeys: string]: Promise<string> | undefined };
private extensionContext : IVSCodeExtensionContext;


constructor(private readonly context: IAcquisitionWorkerContext) {
constructor(private readonly context: IAcquisitionWorkerContext, private readonly utilityContext : IUtilityContext, extensionContext : IVSCodeExtensionContext) {
const dotnetExtension = os.platform() === 'win32' ? '.exe' : '';
this.dotnetExecutable = `dotnet${dotnetExtension}`;
this.timeoutValue = context.timeoutValue;
this.acquisitionPromises = {};
// null deliberately allowed to use old behavior below
this.installingArchitecture = this.context.installingArchitecture === undefined ? os.arch() : this.context.installingArchitecture;
this.globalResolver = null;
this.extensionContext = extensionContext;
}

public async uninstallAll() {
Expand Down Expand Up @@ -289,8 +291,8 @@ export class DotnetCoreAcquisitionWorker implements IDotnetCoreAcquisitionWorker
this.checkForPartialInstalls(installKey, installingVersion, false, false);

const installer : IGlobalInstaller = os.platform() === 'linux' ?
new LinuxGlobalInstaller(this.context, installingVersion) :
new WinMacGlobalInstaller(this.context, installingVersion, await globalInstallerResolver.getInstallerUrl());
new LinuxGlobalInstaller(this.context, this.utilityContext, installingVersion) :
new WinMacGlobalInstaller(this.context, this.utilityContext, installingVersion, await globalInstallerResolver.getInstallerUrl(), await globalInstallerResolver.getInstallerHash());

// Indicate that we're beginning to do the install.
await this.addVersionToExtensionState(this.installingVersionsKey, installKey);
Expand All @@ -316,6 +318,8 @@ export class DotnetCoreAcquisitionWorker implements IDotnetCoreAcquisitionWorker

const installedSDKPath : string = await installer.getExpectedGlobalSDKPath(installingVersion, os.arch());

TelemetryUtilities.setDotnetSDKTelemetryToMatch(this.context.isExtensionTelemetryInitiallyEnabled, this.extensionContext, this.context.eventStream, this.utilityContext);

this.context.installationValidator.validateDotnetInstall(installingVersion, installedSDKPath, true);

this.context.eventStream.post(new DotnetAcquisitionCompleted(installKey, installedSDKPath, installingVersion));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export class GenericDistroSDKProvider extends IDistroDotnetSDKProvider {
if(supportStatus === DotnetDistroSupportStatus.Microsoft)
{
const preinstallCommands = this.myVersionPackages()[this.preinstallCommandKey];
const preparationResult = (await this.commandRunner.execute(preinstallCommands))[0];
for(const feedCommand of preinstallCommands)
{
const preparationResult = (await this.commandRunner.execute(feedCommand))[0];
}
}

let command = this.myDistroCommands()[this.installCommandKey];
Expand Down
Loading