Skip to content

Commit efcba6b

Browse files
authored
Merge pull request dotnet#791 from nagilson/nagilson-list-sdks
Add API Surface to get newest available runtimes + SDKs
2 parents c2b449d + 5d917d4 commit efcba6b

File tree

18 files changed

+414
-148
lines changed

18 files changed

+414
-148
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ project.lock.json
2828
*.ncrunchsolution
2929
*.*sdf
3030
*.ipch
31+
*.js
32+
*.d.ts
33+
*.js.map
3134
.build/
3235
.vs/
3336
launchSettings.json

Documentation/contributing-workflow.md

+11-5
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@ You can contribute to .NET Core with issues and PRs. Simply filing issues for pr
77

88
We use and recommend the following workflow:
99

10-
1. Create an issue for your work.
10+
1. Create an issue for your work.
1111
- You can skip this step for trivial changes.
1212
- Reuse an existing issue on the topic, if there is one.
1313
- Use [CODE_OWNERS.TXT](../CODE_OWNERS.txt) to find relevant maintainers and @ mention them to ask for feedback on your issue.
1414
- Get agreement from the team and the community that your proposed change is a good one.
15-
- If your change adds a new API, follow the [API Review Process](https://github.com/dotnet/corefx/blob/main/Documentation/project-docs/api-review-process.md) (but replace CoreFX with this repo).
15+
- If your change adds a new API, follow the [API Review Process](https://github.com/dotnet/corefx/blob/main/Documentation/project-docs/api-review-process.md) (but replace CoreFX with this repo).
1616
- Clearly state that you are going to take on implementing it, if that's the case. You can request that the issue be assigned to you. Note: The issue filer and the implementer don't have to be the same person.
1717
2. Create a personal fork of the repository on GitHub (if you don't already have one).
18-
3. Create a branch off of main (`git checkout -b mybranch`).
19-
- Name the branch so that it clearly communicates your intentions, such as issue-123 or githubhandle-issue.
18+
3. Create a branch off of main (`git checkout -b mybranch`).
19+
- Name the branch so that it clearly communicates your intentions, such as issue-123 or githubhandle-issue.
2020
- Branches are useful since they isolate your changes from incoming changes from upstream. They also enable you to create multiple PRs from the same fork.
2121
4. Make and commit your changes.
2222
- Please follow our [Commit Messages](contributing.md#commit-messages) guidance.
2323
5. Add new tests corresponding to your change, if applicable.
24+
If you are having difficulty debugging changes, note that you can add breakpoints into the tests for the library, runtime, or SDK by opening their corresponding workspace folder and launching the debug tab for their tests in VS Code. If you want to breakpoint the code, you'll need to breakpoint the test in typescript, but then every reload add breakpoints to the JS code generated from the typescript code if you want to debug code outside of the tests thesmelves that the tests run.
2425
6. Build the repository with your changes.
2526
- Make sure that the builds are clean.
2627
- Make sure that the tests are all passing, including your new tests.
@@ -37,6 +38,11 @@ Note: It is OK to create your PR as "[WIP]" on the upstream repo before the impl
3738

3839
Before making a pull request, be sure to build and test your changes locally with the build script ([windows](https://github.com/dotnet/vscode-dotnet-runtime/blob/main/build.cmd), [mac](https://github.com/dotnet/vscode-dotnet-runtime/blob/main/build.sh)) and test script ([windows](https://github.com/dotnet/vscode-dotnet-runtime/blob/main/test.cmd), [mac](https://github.com/dotnet/vscode-dotnet-runtime/blob/main/test.sh)). To lint your changes, run the test script with the parameter `--tslint`
3940

41+
You can also test only a specific set of tests using the following parameters with the test script:
42+
Test SDK Extension Only: `test sdk` (Tests the SDK extension only.)
43+
Test SDK Extension Only: `test rnt` (Tests the runtime extension only.)
44+
Test SDK Extension Only: `test lib` (Tests the library only.)
45+
4046
## Building a .VSIX
4147

4248
To build an installable .vsix file locally, navigate to the directory containing the extension's package.json (either `vscode-dotnet-runtime-extension` or `vscode-dotnet-sdk-extension`) run the following commands:
@@ -54,7 +60,7 @@ If the CI build fails for any reason, the PR issue will be updated with a link t
5460

5561
## PR Feedback
5662

57-
Microsoft team and community members will provide feedback on your change. Community feedback is highly valued. You will often see the absence of team feedback if the community has already provided good review feedback.
63+
Microsoft team and community members will provide feedback on your change. Community feedback is highly valued. You will often see the absence of team feedback if the community has already provided good review feedback.
5864

5965
1 or more Microsoft team members will review every PR prior to merge. They will often reply with "LGTM, modulo comments". That means that the PR will be merged once the feedback is resolved. "LGTM" == "looks good to me".
6066

sample/package.json

+10-12
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,6 @@
1818
"capabilities": {
1919
"virtualWorkspaces": true
2020
},
21-
"activationEvents": [
22-
"onCommand:sample.helloworld",
23-
"onCommand:sample.dotnet.acquire",
24-
"onCommand:sample.dotnet.acquireStatus",
25-
"onCommand:sample.dotnet.uninstallAll",
26-
"onCommand:sample.dotnet.concurrentTest",
27-
"onCommand:sample.dotnet.showAcquisitionLog",
28-
"onCommand:sample.dotnet-sdk.acquire",
29-
"onCommand:sample.dotnet-sdk.acquireStatus",
30-
"onCommand:sample.dotnet-sdk.uninstallAll",
31-
"onCommand:sample.dotnet-sdk.showAcquisitionLog"
32-
],
3321
"main": "./out/extension.js",
3422
"contributes": {
3523
"commands": [
@@ -82,6 +70,16 @@
8270
"command": "sample.dotnet-sdk.showAcquisitionLog",
8371
"title": "Show .NET SDK acquisition log",
8472
"category": "Sample"
73+
},
74+
{
75+
"command": "sample.dotnet-sdk.listVersions",
76+
"title": "Using the SDK Extension, list the newest versions of the .NET SDK or .NET Runtime.",
77+
"category": "Sample"
78+
},
79+
{
80+
"command": "sample.dotnet-sdk.recommendedVersion",
81+
"title": "Show the recommended version of the SDK to install.",
82+
"category": "Sample"
8583
}
8684
]
8785
},

sample/src/extension.ts

+43-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
import * as cp from 'child_process';
77
import * as path from 'path';
88
import * as vscode from 'vscode';
9-
import { IDotnetAcquireResult } from 'vscode-dotnet-runtime-library';
9+
import {
10+
IDotnetAcquireResult,
11+
IDotnetListVersionsResult,
12+
IDotnetVersion
13+
} from 'vscode-dotnet-runtime-library';
1014
import * as runtimeExtension from 'vscode-dotnet-runtime';
1115
import * as sdkExtension from 'vscode-dotnet-sdk';
1216

@@ -34,6 +38,7 @@ export function activate(context: vscode.ExtensionContext) {
3438
runtimeExtension.activate(context);
3539
sdkExtension.activate(context);
3640

41+
3742
// --------------------------------------------------------------------------
3843

3944
// -------------------runtime extension registrations------------------------
@@ -90,6 +95,7 @@ ${stderr}`);
9095
vscode.window.showErrorMessage((error as Error).toString());
9196
}
9297
});
98+
9399
const sampleAcquireStatusRegistration = vscode.commands.registerCommand('sample.dotnet.acquireStatus', async (version) => {
94100
if (!version) {
95101
version = await vscode.window.showInputBox({
@@ -107,6 +113,7 @@ ${stderr}`);
107113
vscode.window.showErrorMessage((error as Error).toString());
108114
}
109115
});
116+
110117
const sampleDotnetUninstallAllRegistration = vscode.commands.registerCommand('sample.dotnet.uninstallAll', async () => {
111118
try {
112119
await vscode.commands.executeCommand('dotnet.uninstallAll');
@@ -115,6 +122,7 @@ ${stderr}`);
115122
vscode.window.showErrorMessage((error as Error).toString());
116123
}
117124
});
125+
118126
const sampleConcurrentTest = vscode.commands.registerCommand('sample.dotnet.concurrentTest', async () => {
119127
try {
120128
vscode.commands.executeCommand('dotnet.showAcquisitionLog');
@@ -131,6 +139,7 @@ ${stderr}`);
131139
vscode.window.showErrorMessage((error as Error).toString());
132140
}
133141
});
142+
134143
const sampleShowAcquisitionLogRegistration = vscode.commands.registerCommand('sample.dotnet.showAcquisitionLog', async () => {
135144
try {
136145
await vscode.commands.executeCommand('dotnet.showAcquisitionLog');
@@ -145,7 +154,8 @@ ${stderr}`);
145154
sampleAcquireStatusRegistration,
146155
sampleDotnetUninstallAllRegistration,
147156
sampleConcurrentTest,
148-
sampleShowAcquisitionLogRegistration);
157+
sampleShowAcquisitionLogRegistration,
158+
);
149159

150160
// --------------------------------------------------------------------------
151161

@@ -167,6 +177,7 @@ ${stderr}`);
167177
vscode.window.showErrorMessage((error as Error).toString());
168178
}
169179
});
180+
170181
const sampleSDKAcquireStatusRegistration = vscode.commands.registerCommand('sample.dotnet-sdk.acquireStatus', async (version) => {
171182
if (!version) {
172183
version = await vscode.window.showInputBox({
@@ -184,6 +195,33 @@ ${stderr}`);
184195
vscode.window.showErrorMessage((error as Error).toString());
185196
}
186197
});
198+
199+
const sampleSDKlistVersions = vscode.commands.registerCommand('sample.dotnet-sdk.listVersions', async (getRuntimes : boolean) => {
200+
if (!getRuntimes) {
201+
getRuntimes = JSON.parse(await vscode.window.showInputBox({
202+
placeHolder: 'false',
203+
value: 'false',
204+
prompt: 'Acquire Runtimes? Use `true` if so, else, give `false`.',
205+
}) ?? 'false');
206+
}
207+
208+
try {
209+
const result : IDotnetListVersionsResult | undefined = await vscode.commands.executeCommand('dotnet-sdk.listVersions', { listRuntimes: getRuntimes });
210+
vscode.window.showInformationMessage(`Available ${getRuntimes == false ? 'SDKS' : 'Runtimes'}: ${result?.map(x => x.version).join(", ")}`);
211+
} catch (error) {
212+
vscode.window.showErrorMessage((error as Error).toString());
213+
}
214+
});
215+
216+
const sampleSDKrecommendedVersion = vscode.commands.registerCommand('sample.dotnet-sdk.recommendedVersion', async (getRuntimes : boolean) => {
217+
try {
218+
const result : IDotnetVersion | undefined = await vscode.commands.executeCommand('dotnet-sdk.recommendedVersion', { listRuntimes: getRuntimes });
219+
vscode.window.showInformationMessage(`Recommended SDK Version to Install: ${result?.version}`);
220+
} catch (error) {
221+
vscode.window.showErrorMessage((error as Error).toString());
222+
}
223+
});
224+
187225
const sampleSDKDotnetUninstallAllRegistration = vscode.commands.registerCommand('sample.dotnet-sdk.uninstallAll', async () => {
188226
try {
189227
await vscode.commands.executeCommand('dotnet-sdk.uninstallAll');
@@ -192,6 +230,7 @@ ${stderr}`);
192230
vscode.window.showErrorMessage((error as Error).toString());
193231
}
194232
});
233+
195234
const sampleSDKShowAcquisitionLogRegistration = vscode.commands.registerCommand('sample.dotnet-sdk.showAcquisitionLog', async () => {
196235
try {
197236
await vscode.commands.executeCommand('dotnet-sdk.showAcquisitionLog');
@@ -203,6 +242,8 @@ ${stderr}`);
203242
context.subscriptions.push(
204243
sampleSDKAcquireRegistration,
205244
sampleSDKAcquireStatusRegistration,
245+
sampleSDKlistVersions,
246+
sampleSDKrecommendedVersion,
206247
sampleSDKDotnetUninstallAllRegistration,
207248
sampleSDKShowAcquisitionLogRegistration);
208249
}

test.ps1

+49-43
Original file line numberDiff line numberDiff line change
@@ -9,64 +9,70 @@ if ($args[1] -eq '--tslint') {
99
Write-Host "`nTSLint Failed.`n" -ForegroundColor $errorColor
1010
$result = 1
1111
}
12-
else
12+
else
1313
{
1414
Write-Host "`nTSLint Succeeded.`n" -ForegroundColor $successColor
1515
}
1616
}
1717

18-
pushd vscode-dotnet-runtime-library
19-
if (Test-Path node_modules) { rm -r -force node_modules }
20-
npm ci --silent
21-
npm run test
22-
if ($LASTEXITCODE -ne 0)
23-
{
24-
Write-Host "`nAcquisition Library Tests Failed.`n" -ForegroundColor $errorColor
25-
$result = 1
26-
}
27-
else
28-
{
29-
Write-Host "`nAcquisition Library Tests Succeeded.`n" -ForegroundColor $successColor
18+
if ($args[1] -ne 'sdk' -and $args[1] -ne 'rnt') {
19+
pushd vscode-dotnet-runtime-library
20+
if (Test-Path node_modules) { rm -r -force node_modules }
21+
npm ci --silent
22+
npm run test
23+
if ($LASTEXITCODE -ne 0)
24+
{
25+
Write-Host "`nAcquisition Library Tests Failed.`n" -ForegroundColor $errorColor
26+
$result = 1
27+
}
28+
else
29+
{
30+
Write-Host "`nAcquisition Library Tests Succeeded.`n" -ForegroundColor $successColor
31+
}
32+
popd
3033
}
31-
popd
3234

33-
pushd vscode-dotnet-runtime-extension
34-
if (Test-Path node_modules) { rm -r -force node_modules }
35-
npm ci --silent
36-
npm run test
37-
if ($LASTEXITCODE -ne 0)
38-
{
39-
Write-Host "`n.NET Runtime Acquisition Extension Tests Failed.`n" -ForegroundColor $errorColor
40-
$result = 1
41-
}
42-
else
43-
{
44-
Write-Host "`n.NET Runtime Acquisition Extension Tests Succeeded.`n" -ForegroundColor $successColor
35+
if ($args[1] -ne 'sdk' -and $args[1] -ne 'lib') {
36+
pushd vscode-dotnet-runtime-extension
37+
if (Test-Path node_modules) { rm -r -force node_modules }
38+
npm ci --silent
39+
npm run test
40+
if ($LASTEXITCODE -ne 0)
41+
{
42+
Write-Host "`n.NET Runtime Acquisition Extension Tests Failed.`n" -ForegroundColor $errorColor
43+
$result = 1
44+
}
45+
else
46+
{
47+
Write-Host "`n.NET Runtime Acquisition Extension Tests Succeeded.`n" -ForegroundColor $successColor
48+
}
49+
popd
4550
}
46-
popd
4751

48-
pushd vscode-dotnet-sdk-extension
49-
if (Test-Path node_modules) { rm -r -force node_modules }
50-
npm ci --silent
51-
npm run test
52-
if ($LASTEXITCODE -ne 0)
53-
{
54-
Write-Host "`n.NET SDK Acquisition Extension Tests Failed.`n" -ForegroundColor $errorColor
55-
$result = 1
56-
}
57-
else
58-
{
59-
Write-Host "`n.NET SDK Acquisition Extension Tests Succeeded.`n" -ForegroundColor $successColor
52+
if ($args[1] -ne 'lib' -and $args[1] -ne 'rnt') {
53+
pushd vscode-dotnet-sdk-extension
54+
if (Test-Path node_modules) { rm -r -force node_modules }
55+
npm ci --silent
56+
npm run test
57+
if ($LASTEXITCODE -ne 0)
58+
{
59+
Write-Host "`n.NET SDK Acquisition Extension Tests Failed.`n" -ForegroundColor $errorColor
60+
$result = 1
61+
}
62+
else
63+
{
64+
Write-Host "`n.NET SDK Acquisition Extension Tests Succeeded.`n" -ForegroundColor $successColor
65+
}
66+
popd
6067
}
61-
popd
6268

63-
if ($result -ne 0)
69+
if ($result -ne 0)
6470
{
6571
Write-Host "`n`nTests Failed.`n" -ForegroundColor $errorColor
6672
exit $result
6773
}
68-
else
74+
else
6975
{
70-
Write-Host "`n`nAll Tests Succeeded.`n" -ForegroundColor $successColor
76+
Write-Host "`n`nAll Tests Succeeded.`n" -ForegroundColor $successColor
7177
exit $result
7278
}

vscode-dotnet-runtime-extension/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
"onCommand:dotnet.acquireStatus",
3939
"onCommand:dotnet.uninstallAll",
4040
"onCommand:dotnet.showAcquisitionLog",
41-
"onCommand:dotnet.ensureDotnetDependencies",
42-
"onCommand:dotnet.reportIssue"
41+
"onCommand:dotnet.ensureDotnetDependencies"
4342
],
4443
"main": "./dist/extension.js",
4544
"types": "./dist/extension.d.ts",

vscode-dotnet-runtime-extension/src/extension.ts

+7
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
WindowDisplayWorker,
3939
} from 'vscode-dotnet-runtime-library';
4040
import { dotnetCoreAcquisitionExtensionId } from './DotnetCoreAcquistionId';
41+
4142
// tslint:disable no-var-requires
4243
const packageJson = require('../package.json');
4344

@@ -55,6 +56,7 @@ namespace commandKeys {
5556
export const ensureDotnetDependencies = 'ensureDotnetDependencies';
5657
export const reportIssue = 'reportIssue';
5758
}
59+
5860
const commandPrefix = 'dotnet';
5961
const configPrefix = 'dotnetAcquisitionExtension';
6062
const displayChannelName = '.NET Runtime';
@@ -130,6 +132,7 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
130132
}, issueContext(commandContext.errorConfiguration, 'acquire', commandContext.version), commandContext.requestingExtensionId);
131133
return dotnetPath;
132134
});
135+
133136
const dotnetAcquireStatusRegistration = vscode.commands.registerCommand(`${commandPrefix}.${commandKeys.acquireStatus}`, async (commandContext: IDotnetAcquireContext) => {
134137
const pathResult = callWithErrorHandling(async () => {
135138
eventStream.post(new DotnetAcquisitionStatusRequested(commandContext.version, commandContext.requestingExtensionId));
@@ -139,10 +142,13 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
139142
}, issueContext(commandContext.errorConfiguration, 'acquireRuntimeStatus'));
140143
return pathResult;
141144
});
145+
142146
const dotnetUninstallAllRegistration = vscode.commands.registerCommand(`${commandPrefix}.${commandKeys.uninstallAll}`, async (commandContext: IDotnetUninstallContext | undefined) => {
143147
await callWithErrorHandling(() => acquisitionWorker.uninstallAll(), issueContext(commandContext ? commandContext.errorConfiguration : undefined, 'uninstallAll'));
144148
});
149+
145150
const showOutputChannelRegistration = vscode.commands.registerCommand(`${commandPrefix}.${commandKeys.showAcquisitionLog}`, () => outputChannel.show(/* preserveFocus */ false));
151+
146152
const ensureDependenciesRegistration = vscode.commands.registerCommand(`${commandPrefix}.${commandKeys.ensureDotnetDependencies}`, async (commandContext: IDotnetEnsureDependenciesContext) => {
147153
await callWithErrorHandling(async () => {
148154
if (os.platform() !== 'linux') {
@@ -158,6 +164,7 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
158164
}
159165
}, issueContext(commandContext.errorConfiguration, 'ensureDependencies'));
160166
});
167+
161168
const reportIssueRegistration = vscode.commands.registerCommand(`${commandPrefix}.${commandKeys.reportIssue}`, async () => {
162169
const [url, issueBody] = formatIssueUrl(undefined, issueContext(AcquireErrorConfiguration.DisableErrorPopups, 'reportIssue'));
163170
await vscode.env.clipboard.writeText(issueBody);

0 commit comments

Comments
 (0)