Skip to content

Commit 3659364

Browse files
authored
Add Support for ASP.NET Installation (#1843)
* 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
1 parent 0655891 commit 3659364

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+845
-405
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"proccom",
1313
"programfiles",
1414
"REGHEXVALUE",
15-
"REGTYPE"
15+
"REGTYPE",
16+
"Republisher"
1617
],
1718
"azure-pipelines.1ESPipelineTemplatesSchemaFile": true
1819
}

sample/package-lock.json

Lines changed: 31 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
"title": "Acquire .NET runtime",
3232
"category": "Sample"
3333
},
34+
{
35+
"command": "sample.dotnet.acquireASPNET",
36+
"title": "Acquire ASPNET runtime",
37+
"category": "Sample"
38+
},
3439
{
3540
"command": "sample.dotnet.acquireStatus",
3641
"title": "Check the status of acquiring the .NET runtime",
@@ -46,6 +51,11 @@
4651
"title": "Concurrently acquire all 2.X .NET Core runtimes",
4752
"category": "Sample"
4853
},
54+
{
55+
"command": "sample.dotnet.concurrentASPNETTest",
56+
"title": "Concurrently acquire all 2.X ASPNET Core runtimes",
57+
"category": "Sample"
58+
},
4959
{
5060
"command": "sample.dotnet.showAcquisitionLog",
5161
"title": "Show .NET runtime acquisition log",
@@ -112,6 +122,7 @@
112122
"@types/mocha": "9.0.0",
113123
"@types/node": "16.11.7",
114124
"@types/rimraf": "3.0.2",
125+
"@types/source-map-support": "^0.5.10",
115126
"@types/vscode": "1.74.0",
116127
"mocha": "^9.2.2",
117128
"rimraf": "3.0.2",

sample/src/extension.ts

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ import * as cp from 'child_process';
77
import * as path from 'path';
88
import * as vscode from 'vscode';
99
import {
10+
DotnetInstallMode,
1011
IDotnetAcquireContext,
1112
IDotnetAcquireResult,
1213
IDotnetListVersionsResult,
13-
IDotnetVersion,
1414
} from 'vscode-dotnet-runtime-library';
1515
import * as runtimeExtension from 'vscode-dotnet-runtime';
1616
import * as sdkExtension from 'vscode-dotnet-sdk';
17+
import { install } from 'source-map-support';
1718

1819
export function activate(context: vscode.ExtensionContext) {
1920

@@ -76,7 +77,8 @@ ${stderr}`);
7677
}
7778
});
7879

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

8890
try {
8991
await vscode.commands.executeCommand('dotnet.showAcquisitionLog');
90-
await vscode.commands.executeCommand('dotnet.acquire', { version, requestingExtensionId });
92+
await vscode.commands.executeCommand('dotnet.acquire', { version, requestingExtensionId, mode: installMode });
9193
} catch (error) {
9294
vscode.window.showErrorMessage((error as Error).toString());
9395
}
96+
}
97+
98+
const sampleAcquireRegistration = vscode.commands.registerCommand('sample.dotnet.acquire', async (version) => {
99+
await callAcquireAPI(version, undefined);
100+
});
101+
102+
const sampleAcquireASPNETRegistration = vscode.commands.registerCommand('sample.dotnet.acquireASPNET', async (version) => {
103+
await callAcquireAPI(version, 'aspnetcore' );
94104
});
95105

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

123-
const sampleConcurrentTest = vscode.commands.registerCommand('sample.dotnet.concurrentTest', async () => {
124-
try {
133+
async function acquireConcurrent(versions : [string, string, string], installMode? : DotnetInstallMode)
134+
{
135+
try
136+
{
125137
vscode.commands.executeCommand('dotnet.showAcquisitionLog');
126138
const promises = [
127-
vscode.commands.executeCommand('dotnet.acquire', { version: '2.0', requestingExtensionId }),
128-
vscode.commands.executeCommand('dotnet.acquire', { version: '2.1', requestingExtensionId }),
129-
vscode.commands.executeCommand('dotnet.acquire', { version: '2.2', requestingExtensionId })];
139+
vscode.commands.executeCommand('dotnet.acquire', { version: versions[0], requestingExtensionId, mode: installMode }),
140+
vscode.commands.executeCommand('dotnet.acquire', { version: versions[1], requestingExtensionId, mode: installMode }),
141+
vscode.commands.executeCommand('dotnet.acquire', { version: versions[2], requestingExtensionId, mode: installMode })];
130142

131-
for (const promise of promises) {
143+
for (const promise of promises)
144+
{
132145
// Await here so we can detect errors
133146
await promise;
134147
}
135-
} catch (error) {
148+
} catch (error)
149+
{
136150
vscode.window.showErrorMessage((error as Error).toString());
137151
}
152+
}
153+
154+
const sampleConcurrentTest = vscode.commands.registerCommand('sample.dotnet.concurrentTest', async () => {
155+
await acquireConcurrent(['2.0', '2.1', '2.2'], 'runtime');
156+
});
157+
158+
const sampleConcurrentASPNETTest = vscode.commands.registerCommand('sample.dotnet.concurrentASPNETTest', async () => {
159+
await acquireConcurrent(['2.0', '2.1', '2.2'], 'aspnetcore');
138160
});
139161

140162
const sampleShowAcquisitionLogRegistration = vscode.commands.registerCommand('sample.dotnet.showAcquisitionLog', async () => {
@@ -148,9 +170,11 @@ ${stderr}`);
148170
context.subscriptions.push(
149171
sampleHelloWorldRegistration,
150172
sampleAcquireRegistration,
173+
sampleAcquireASPNETRegistration,
151174
sampleAcquireStatusRegistration,
152175
sampleDotnetUninstallAllRegistration,
153176
sampleConcurrentTest,
177+
sampleConcurrentASPNETTest,
154178
sampleShowAcquisitionLogRegistration,
155179
);
156180

sample/yarn.lock

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@
121121
"@types/glob" "*"
122122
"@types/node" "*"
123123

124+
"@types/source-map-support@^0.5.10":
125+
"integrity" "sha1-gk3O+YlJa66Y6dBMjcGsHXDhvTk="
126+
"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"
127+
"version" "0.5.10"
128+
dependencies:
129+
"source-map" "^0.6.0"
130+
124131
125132
"integrity" "sha1-StwhtOf1J7iT3jQYwhqR8eUDvc0="
126133
"resolved" "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@types/vscode/-/vscode-1.74.0.tgz"
@@ -1814,6 +1821,7 @@
18141821
"proper-lockfile" "^4.1.2"
18151822
"rimraf" "3.0.2"
18161823
"run-script-os" "^1.1.6"
1824+
"semver" "^7.6.2"
18171825
"shelljs" "0.8.5"
18181826
"typescript" "4.4.4"
18191827
"vscode-extension-telemetry" "^0.4.3"
@@ -1823,7 +1831,7 @@
18231831

18241832
"vscode-dotnet-runtime@file:../vscode-dotnet-runtime-extension":
18251833
"resolved" "file:../vscode-dotnet-runtime-extension"
1826-
"version" "2.0.6"
1834+
"version" "2.0.7"
18271835
dependencies:
18281836
"@types/chai-as-promised" "^7.1.8"
18291837
"@vscode/test-electron" "^2.3.9"
@@ -1837,6 +1845,7 @@
18371845
"open" "^8.4.0"
18381846
"rimraf" "3.0.2"
18391847
"shelljs" "^0.8.5"
1848+
"ts-loader" "^9.5.1"
18401849
"typescript" "4.4.4"
18411850
"vscode-dotnet-runtime-library" "file:../vscode-dotnet-runtime-library"
18421851
"webpack-permissions-plugin" "^1.0.9"
@@ -1865,6 +1874,7 @@
18651874
"run-script-os" "^1.1.6"
18661875
"shelljs" "^0.8.5"
18671876
"source-map-support" "^0.5.21"
1877+
"ts-loader" "^9.5.1"
18681878
"typescript" "4.4.4"
18691879
"vscode-dotnet-runtime-library" "file:../vscode-dotnet-runtime-library"
18701880

vscode-dotnet-runtime-extension/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning].
77

88
## [Unreleased]
99

10+
## [2.0.7] - 2024-06-30
11+
12+
Adds support for ASP.NET Core Runtime installation via the `acquire` API.
13+
14+
15+
Smaller bug fixes for error handling and reporting.
16+
Updated dependencies and added additional notices to our main page.
17+
1018
## [2.0.6] - 2024-06-10
1119

1220
Keeps track of which extensions manage which installs to allow for better cleanup of old runtimes and sdks.

vscode-dotnet-runtime-extension/package-lock.json

Lines changed: 22 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)