Skip to content
Open
Changes from all commits
Commits
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
44 changes: 26 additions & 18 deletions vscode-dotnet-runtime-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,27 +575,35 @@ export function activate(vsCodeContext: vscode.ExtensionContext, extensionContex

const dotnetUninstallPublicRegistration = vscode.commands.registerCommand(`${commandPrefix}.${commandKeys.uninstallPublic}`, async () =>
{
const existingInstalls: InstallRecord[] = await InstallTrackerSingleton.getInstance(globalEventStream, vsCodeContext.globalState).getExistingInstalls(directoryProviderFactory(
'runtime', vsCodeContext.globalStoragePath));

const menuItems = existingInstalls?.sort(
function (x: InstallRecord, y: InstallRecord): number
const compareVersions = (x: InstallRecord, y: InstallRecord): number =>
{
const xParts = x.dotnetInstall.version.split('.').map(part => Number(part.split('-')[0]));
const yParts = y.dotnetInstall.version.split('.').map(part => Number(part.split('-')[0]));
const length = Math.max(xParts.length, yParts.length);
for (let index = 0; index < length; index++)
{
if (x.dotnetInstall.installMode === y.dotnetInstall.installMode)
const difference = (xParts[index] ?? 0) - (yParts[index] ?? 0);
if (difference !== 0)
{
return x.dotnetInstall.version.localeCompare(y.dotnetInstall.version);
return difference;
}
return x.dotnetInstall.installMode.localeCompare(y.dotnetInstall.installMode);
})?.map(install =>
{
return {
label: `.NET ${(install.dotnetInstall.installMode === 'sdk' ? 'SDK' : install.dotnetInstall.installMode === 'runtime' ? 'Runtime' : 'ASP.NET Core Runtime')} ${install.dotnetInstall.version}`,
description: `${install.dotnetInstall.architecture ?? ''} | ${install.dotnetInstall.isGlobal ? 'machine-wide' : 'vscode-local'}`,
detail: install.installingExtensions.some(x => x !== null) ? `Used by ${install.installingExtensions.join(', ')}` : ``,
iconPath: install.dotnetInstall.isGlobal ? new vscode.ThemeIcon('shield') : new vscode.ThemeIcon('trash'),
internalId: install.dotnetInstall.installId
}
});
}
return 0;
};

const existingInstalls: InstallRecord[] = await InstallTrackerSingleton.getInstance(globalEventStream, vsCodeContext.globalState).getExistingInstalls(directoryProviderFactory(
'runtime', vsCodeContext.globalStoragePath));

const menuItems = existingInstalls?.sort(compareVersions)?.map(install =>
{
return {
label: `.NET ${(install.dotnetInstall.installMode === 'sdk' ? 'SDK' : install.dotnetInstall.installMode === 'runtime' ? 'Runtime' : 'ASP.NET Core Runtime')} ${install.dotnetInstall.version}`,
description: `${install.dotnetInstall.architecture ?? ''} | ${install.dotnetInstall.isGlobal ? 'machine-wide' : 'vscode-local'}`,
detail: install.installingExtensions.some(x => x !== null) ? `Used by ${install.installingExtensions.join(', ')}` : ``,
iconPath: install.dotnetInstall.isGlobal ? new vscode.ThemeIcon('shield') : new vscode.ThemeIcon('trash'),
internalId: install.dotnetInstall.installId
}
});

if ((menuItems?.length ?? 0) < 1)
{
Expand Down