Add preview flag to enable public command

This commit is contained in:
Noah Gilson 2024-02-05 12:36:51 -08:00
Родитель 001f2d92c9
Коммит 6bdfdb788e
4 изменённых файлов: 28 добавлений и 5 удалений

Просмотреть файл

@ -17,10 +17,13 @@ This extension was probably included as a dependency of one of the following ext
The above extensions call into this extension to provide a unified way of downloading shared .NET Runtimes or .NET SDKs. If you already have an installation of .NET that you'd like to use, see [the troubleshooting section below](#i-already-have-a-net-runtime-or-sdk-installed-and-i-want-to-use-it). If you want to remove this extension completely, you will need to uninstall any extensions that depend on it first. If this extension is uninstalled, any .NET Runtimes installed by it will also be removed.
## Using the extension yourself
## [Preview ]Using the extension yourself
As of version 2.0.2, you can install the .NET SDK using part of our private API via the VS Code Command Palette!
This feature is in preview and still undergoing testing. To use it, you must enable preview features for the extension.
To do so, go to the 'Extensions' tab in VS Code, right click the '.NET Install Tool' and go to 'Extension Settings', then click the box to Enable Preview Features.
To then use the feature:
Bring up the command palette (ctrl + shift + p) and run the command:
.NET Install Tool - Install the .NET SDK System-Wide.

Просмотреть файл

@ -56,7 +56,8 @@
{
"command": "dotnet.acquireGlobalSDKPublic",
"title": "Install the .NET SDK System-Wide.",
"category": ".NET Install Tool"
"category": ".NET Install Tool",
"enablement": "config.dotnetAcquisitionExtension.enablePreviewFeatures && dotnetAcquisitionExtension.isGlobalSDKSupported !== false"
}
],
"configuration": {
@ -67,6 +68,11 @@
"default": true,
"description": "Enable Telemetry for the .NET Install Tool. Restart VS Code to apply changes."
},
"dotnetAcquisitionExtension.enablePreviewFeatures": {
"type": "boolean",
"default": false,
"description": "Enable Preview Features for the Extension. Restart VS Code to apply changes."
},
"dotnetAcquisitionExtension.installTimeoutValue": {
"type": "number",
"default": 600,
@ -75,7 +81,11 @@
"dotnetAcquisitionExtension.existingDotnetPath": {
"type": "array",
"description": "File Path to an existing installation of .NET. Used for both the .NET SDK and .NET Runtime.",
"examples": ["C:\\Program Files\\dotnet\\dotnet.exe", "/usr/local/share/dotnet/dotnet", "/usr/lib/dotnet/dotnet"]
"examples": [
"C:\\Program Files\\dotnet\\dotnet.exe",
"/usr/local/share/dotnet/dotnet",
"/usr/lib/dotnet/dotnet"
]
},
"dotnetAcquisitionExtension.proxyUrl": {
"type": "string",

Просмотреть файл

@ -136,6 +136,8 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
const sdkIssueContextFunctor = getIssueContext(existingPathConfigWorker);
const sdkAcquisitionWorker = getAcquisitionWorker(sdkContext);
checkIfSDKAcquisitionIsSupported();
// Creating API Surfaces
const dotnetAcquireRegistration = vscode.commands.registerCommand(`${commandPrefix}.${commandKeys.acquire}`, async (commandContext: IDotnetAcquireContext) => {
let fullyResolvedVersion = '';
@ -319,6 +321,14 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
});
}
function checkIfSDKAcquisitionIsSupported() : boolean
{
let isSupported = true;
isSupported = isSupported && !CommandExecutor.isRunningUnderWSL();
vscode.commands.executeCommand('setContext', 'dotnetAcquisitionExtension.isGlobalSDKSupported', isSupported);
return isSupported;
}
const getAvailableVersions = async (commandContext: IDotnetListVersionsContext | undefined,
customWebWorker: WebRequestWorker | undefined, onRecommendationMode : boolean) : Promise<IDotnetListVersionsResult | undefined> =>
{

Просмотреть файл

@ -50,7 +50,7 @@ export class CommandExecutor extends ICommandExecutor
/**
* Returns true if the linux agent is running under WSL, else false.
*/
private isRunningUnderWSL() : boolean
public static isRunningUnderWSL() : boolean
{
// See https://github.com/microsoft/WSL/issues/4071 for evidence that we can rely on this behavior.
@ -70,7 +70,7 @@ export class CommandExecutor extends ICommandExecutor
const fullCommandString = CommandExecutor.prettifyCommandExecutorCommand(command, false);
this.context?.eventStream.post(new CommandExecutionUnderSudoEvent(`The command ${fullCommandString} is being ran under sudo.`));
if(this.isRunningUnderWSL())
if(CommandExecutor.isRunningUnderWSL())
{
// For WSL, vscode/sudo-prompt does not work.
// This is because it relies on pkexec or a GUI app to popup and request sudo privilege.