Skip to content

Commit

Permalink
Add Support for ASP.NET Installation (#1843)
Browse files Browse the repository at this point in the history
* wip - separate out worker paths so contexts are needed for every call, but there is less potential for things to go wrong and less code duplication

* Further isolate code, need to isolate the install tracker now

* migrate install tracker to use event stream instead of being coupled to the context

* move installtracker to a singleton and fix tests

the install tracker really only needs to exist once since the event stream and extension state are global, this will prevent errors from different states of promises and simplify our code with this design pattern to decouple the installation tracking mechanism from the context object, which will reduce code duplication for aspnet install feature additions

* Fix some issues with the test during code migration

* Fix issue with accessing instance

I forgot to ctrl s!

* Clean up logic with install key generation

* Remove duplicate source of truth for architecture

* Improve logging and error handling of install tracker

This class is super annoying to debug without better logging

* Update some broken components of the tests

* Prevent saying object object in the log output by expanding the object

* Tests working

We used to need to concat these tests results with different contexts but not any longer

* FIx uninstall all commands

* Fix the file rename

* Improve logging messages

* Add mode handling for aspnet

* Add ASP NET Support

* Add Generic -> Mode Specific Event Stream Class Hierarchy

* [wip] create events for all 'modal' events

* Dont hold a generic arg obj because it becomes too unwieldy

* Fix some issues with the test and sdk extension

* Add 'mode' to the acquire context

This will allow API callers to set the mode to call aspnet without having to write a new endpoint call. We can default to runtime for when it wasnt provided that would be the old behavior.

* Move 'installMode' into the acquire context

This allows API callers to provide the mode,
We remove it from the worker context to dedupe this and prevent 2x sources of truth.

Now this is a bit weird because some API endpoints will take the mode even though the API endpoint is only for one mode. We will just ignore the mode for that. Eventually we can try to transition all of the related calls to a single endpoint based on 'mode' which would simplify API usage.

* Code cleanup

* De-Dupe Test Code

* Add Requested Events to Republisher

* Update InstallKey pattern to include ~aspnetcore

This is a bit strange since - used to be for 'global' and ~ for architecture. There are only so many path safe characters to use, more importantly though we dont rely on the install key as the information for the install anymore, it is stored in the DotnetInstall object. ~ has logic in place to not account for a 'legacy' install, so ~ with aspnet (which would not have existed before arch was added) is also a bet that will work with pre-existing logic.

* fix build issues

* Add ASP.NET Directory Provider

* Only Report Total Success if Path exists

The path can be undefined if an error throws so its not a success

* Add ASP.NET API to sample extension

* Resolve Asp Net Runtime versions as Runtime versions

* Fix mistake on test

* Fix bug with install script param

* add source-map-support to allow build in CI

this got removed and passed earlier somehow

* respond to linter

* add source map support

* Respond to linter

* Add test for specific telemetry messages

* 2.0.7 branding

* Prevent circular import

* rewrite completion event so we can test the modaleventrepublisher

* fix linter issue

* Revert new test since the object is not mockable

* Get rid of check for event that cannot be published via mocks

* Fix bug where logging was not up to date

to prevent i/o costs the file is dumped at the end of error handling, but this means other events past error handling dont get added to the log. This fixes this.

* respond to pr feedback
  • Loading branch information
nagilson authored Jun 25, 2024
1 parent 0655891 commit 3659364
Show file tree
Hide file tree
Showing 45 changed files with 845 additions and 405 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"proccom",
"programfiles",
"REGHEXVALUE",
"REGTYPE"
"REGTYPE",
"Republisher"
],
"azure-pipelines.1ESPipelineTemplatesSchemaFile": true
}
34 changes: 31 additions & 3 deletions sample/package-lock.json

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

11 changes: 11 additions & 0 deletions sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
"title": "Acquire .NET runtime",
"category": "Sample"
},
{
"command": "sample.dotnet.acquireASPNET",
"title": "Acquire ASPNET runtime",
"category": "Sample"
},
{
"command": "sample.dotnet.acquireStatus",
"title": "Check the status of acquiring the .NET runtime",
Expand All @@ -46,6 +51,11 @@
"title": "Concurrently acquire all 2.X .NET Core runtimes",
"category": "Sample"
},
{
"command": "sample.dotnet.concurrentASPNETTest",
"title": "Concurrently acquire all 2.X ASPNET Core runtimes",
"category": "Sample"
},
{
"command": "sample.dotnet.showAcquisitionLog",
"title": "Show .NET runtime acquisition log",
Expand Down Expand Up @@ -112,6 +122,7 @@
"@types/mocha": "9.0.0",
"@types/node": "16.11.7",
"@types/rimraf": "3.0.2",
"@types/source-map-support": "^0.5.10",
"@types/vscode": "1.74.0",
"mocha": "^9.2.2",
"rimraf": "3.0.2",
Expand Down
44 changes: 34 additions & 10 deletions sample/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import * as cp from 'child_process';
import * as path from 'path';
import * as vscode from 'vscode';
import {
DotnetInstallMode,
IDotnetAcquireContext,
IDotnetAcquireResult,
IDotnetListVersionsResult,
IDotnetVersion,
} from 'vscode-dotnet-runtime-library';
import * as runtimeExtension from 'vscode-dotnet-runtime';
import * as sdkExtension from 'vscode-dotnet-sdk';
import { install } from 'source-map-support';

export function activate(context: vscode.ExtensionContext) {

Expand Down Expand Up @@ -76,7 +77,8 @@ ${stderr}`);
}
});

const sampleAcquireRegistration = vscode.commands.registerCommand('sample.dotnet.acquire', async (version) => {
async function callAcquireAPI(version : string | undefined, installMode : DotnetInstallMode | undefined)
{
if (!version) {
version = await vscode.window.showInputBox({
placeHolder: '3.1',
Expand All @@ -87,10 +89,18 @@ ${stderr}`);

try {
await vscode.commands.executeCommand('dotnet.showAcquisitionLog');
await vscode.commands.executeCommand('dotnet.acquire', { version, requestingExtensionId });
await vscode.commands.executeCommand('dotnet.acquire', { version, requestingExtensionId, mode: installMode });
} catch (error) {
vscode.window.showErrorMessage((error as Error).toString());
}
}

const sampleAcquireRegistration = vscode.commands.registerCommand('sample.dotnet.acquire', async (version) => {
await callAcquireAPI(version, undefined);
});

const sampleAcquireASPNETRegistration = vscode.commands.registerCommand('sample.dotnet.acquireASPNET', async (version) => {
await callAcquireAPI(version, 'aspnetcore' );
});

const sampleAcquireStatusRegistration = vscode.commands.registerCommand('sample.dotnet.acquireStatus', async (version) => {
Expand Down Expand Up @@ -120,21 +130,33 @@ ${stderr}`);
}
});

const sampleConcurrentTest = vscode.commands.registerCommand('sample.dotnet.concurrentTest', async () => {
try {
async function acquireConcurrent(versions : [string, string, string], installMode? : DotnetInstallMode)
{
try
{
vscode.commands.executeCommand('dotnet.showAcquisitionLog');
const promises = [
vscode.commands.executeCommand('dotnet.acquire', { version: '2.0', requestingExtensionId }),
vscode.commands.executeCommand('dotnet.acquire', { version: '2.1', requestingExtensionId }),
vscode.commands.executeCommand('dotnet.acquire', { version: '2.2', requestingExtensionId })];
vscode.commands.executeCommand('dotnet.acquire', { version: versions[0], requestingExtensionId, mode: installMode }),
vscode.commands.executeCommand('dotnet.acquire', { version: versions[1], requestingExtensionId, mode: installMode }),
vscode.commands.executeCommand('dotnet.acquire', { version: versions[2], requestingExtensionId, mode: installMode })];

for (const promise of promises) {
for (const promise of promises)
{
// Await here so we can detect errors
await promise;
}
} catch (error) {
} catch (error)
{
vscode.window.showErrorMessage((error as Error).toString());
}
}

const sampleConcurrentTest = vscode.commands.registerCommand('sample.dotnet.concurrentTest', async () => {
await acquireConcurrent(['2.0', '2.1', '2.2'], 'runtime');
});

const sampleConcurrentASPNETTest = vscode.commands.registerCommand('sample.dotnet.concurrentASPNETTest', async () => {
await acquireConcurrent(['2.0', '2.1', '2.2'], 'aspnetcore');
});

const sampleShowAcquisitionLogRegistration = vscode.commands.registerCommand('sample.dotnet.showAcquisitionLog', async () => {
Expand All @@ -148,9 +170,11 @@ ${stderr}`);
context.subscriptions.push(
sampleHelloWorldRegistration,
sampleAcquireRegistration,
sampleAcquireASPNETRegistration,
sampleAcquireStatusRegistration,
sampleDotnetUninstallAllRegistration,
sampleConcurrentTest,
sampleConcurrentASPNETTest,
sampleShowAcquisitionLogRegistration,
);

Expand Down
12 changes: 11 additions & 1 deletion sample/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@
"@types/glob" "*"
"@types/node" "*"

"@types/source-map-support@^0.5.10":
"integrity" "sha1-gk3O+YlJa66Y6dBMjcGsHXDhvTk="
"resolved" "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@types/source-map-support/-/source-map-support-0.5.10.tgz"
"version" "0.5.10"
dependencies:
"source-map" "^0.6.0"

"@types/vscode@1.74.0":
"integrity" "sha1-StwhtOf1J7iT3jQYwhqR8eUDvc0="
"resolved" "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@types/vscode/-/vscode-1.74.0.tgz"
Expand Down Expand Up @@ -1814,6 +1821,7 @@
"proper-lockfile" "^4.1.2"
"rimraf" "3.0.2"
"run-script-os" "^1.1.6"
"semver" "^7.6.2"
"shelljs" "0.8.5"
"typescript" "4.4.4"
"vscode-extension-telemetry" "^0.4.3"
Expand All @@ -1823,7 +1831,7 @@

"vscode-dotnet-runtime@file:../vscode-dotnet-runtime-extension":
"resolved" "file:../vscode-dotnet-runtime-extension"
"version" "2.0.6"
"version" "2.0.7"
dependencies:
"@types/chai-as-promised" "^7.1.8"
"@vscode/test-electron" "^2.3.9"
Expand All @@ -1837,6 +1845,7 @@
"open" "^8.4.0"
"rimraf" "3.0.2"
"shelljs" "^0.8.5"
"ts-loader" "^9.5.1"
"typescript" "4.4.4"
"vscode-dotnet-runtime-library" "file:../vscode-dotnet-runtime-library"
"webpack-permissions-plugin" "^1.0.9"
Expand Down Expand Up @@ -1865,6 +1874,7 @@
"run-script-os" "^1.1.6"
"shelljs" "^0.8.5"
"source-map-support" "^0.5.21"
"ts-loader" "^9.5.1"
"typescript" "4.4.4"
"vscode-dotnet-runtime-library" "file:../vscode-dotnet-runtime-library"

Expand Down
8 changes: 8 additions & 0 deletions vscode-dotnet-runtime-extension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning].

## [Unreleased]

## [2.0.7] - 2024-06-30

Adds support for ASP.NET Core Runtime installation via the `acquire` API.


Smaller bug fixes for error handling and reporting.
Updated dependencies and added additional notices to our main page.

## [2.0.6] - 2024-06-10

Keeps track of which extensions manage which installs to allow for better cleanup of old runtimes and sdks.
Expand Down
24 changes: 22 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.

Loading

0 comments on commit 3659364

Please sign in to comment.