Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow uninstallation of global .NET Installations #1897

Merged
merged 58 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
e145056
Add failure handling for file integrity check
nagilson Jul 15, 2024
ef19190
elevate on windows
nagilson Jul 15, 2024
41ca32a
Retry if no permission is available the first time
nagilson Jul 15, 2024
6f986f2
Merge remote-tracking branch 'upstream/main' into nagilson-elevate-wi…
nagilson Jul 16, 2024
d8ac784
respond to linter
nagilson Jul 16, 2024
59e8137
Add API to uninstall any install
nagilson Jul 24, 2024
a0380ed
Add tests
nagilson Jul 24, 2024
d1883be
undo bad save
nagilson Jul 24, 2024
0d6b3f3
dont uninstall if there are multiple owners
nagilson Jul 24, 2024
164ca0a
add some basic uninstall capability
nagilson Jul 29, 2024
b223000
Merge branch 'main' into nagilson-elevate-windows
nagilson Jul 29, 2024
669c934
allow elevation on mac
nagilson Jul 29, 2024
316757a
fix promise chain a bit, may need to await still
nagilson Jul 29, 2024
f422c4c
add uninstall functionality to linux
nagilson Jul 29, 2024
b095839
add uninstall on linux
nagilson Jul 31, 2024
bdf3f3a
Merge branch 'main' into nagilson-elevate-windows
nagilson Aug 5, 2024
07ae0fe
Merge branch 'main' into nagilson-uninstall-global
nagilson Aug 6, 2024
78660f5
fix merge
nagilson Aug 6, 2024
5530d74
Add a test
nagilson Aug 6, 2024
c046931
add ui element to pick uninstall
nagilson Aug 6, 2024
1d6363b
add some output, need to test and check graveyard
nagilson Aug 6, 2024
fc09197
add uninstall events
nagilson Aug 6, 2024
9f1a043
Merge branch 'main' into nagilson-uninstall-global
nagilson Aug 6, 2024
c56abff
fix build
nagilson Aug 6, 2024
799681a
Fix uninstall to pop up above window
nagilson Aug 6, 2024
9f7ce49
ui changes per request
nagilson Aug 6, 2024
823d566
fix test
nagilson Aug 6, 2024
c498253
Merge branch 'nagilson-elevate-windows' into nagilson-uninstall-global
nagilson Aug 7, 2024
5657ea2
fix merge err
nagilson Aug 7, 2024
00c555a
fix mac test
nagilson Aug 7, 2024
8381812
Merge remote-tracking branch 'upstream/main' into nagilson-uninstall-…
nagilson Aug 7, 2024
e5fe342
fix name option
nagilson Aug 7, 2024
94edcd8
fix promise logic
nagilson Aug 7, 2024
1de3ffb
fix promise code again xd
nagilson Aug 7, 2024
c08dd69
Merge branch 'main' into nagilson-uninstall-global
nagilson Aug 12, 2024
61c1df2
Add icons for the extension
nagilson Aug 12, 2024
1a855cd
add icons to shield and uninstall
nagilson Aug 12, 2024
24b55cf
set minimum vscode version to require new icons
nagilson Aug 12, 2024
0a84834
dont sort if no install exists
nagilson Aug 12, 2024
f3a3cee
use noninteractive frontend in master process to fix dpk unable to re…
nagilson Aug 12, 2024
0cb297e
try to exit sudo process master and set env var for stdin uninstall fix
nagilson Aug 12, 2024
22a5ae6
fix eventstream
nagilson Aug 12, 2024
2f698d4
fix detection logic for uninstall
nagilson Aug 12, 2024
84a1792
add -y to uninstall
nagilson Aug 12, 2024
ad3a35a
fix bug with uninstall
nagilson Aug 12, 2024
f0604c9
add version check for when disk is full and version string ui fails
nagilson Aug 13, 2024
e654747
also kill sudo process on uninstall
nagilson Aug 13, 2024
19d3350
use -f to delete file as they may not exist and we dont want to fail …
nagilson Aug 13, 2024
117f315
add -y to update
nagilson Aug 13, 2024
0f44201
respond to linter
nagilson Aug 13, 2024
aa2b240
remove unnecessary img
nagilson Aug 13, 2024
91fd6b1
respond to linter
nagilson Aug 13, 2024
e84cd6c
respond to pr feedback
nagilson Aug 13, 2024
eb361b2
Merge branch 'main' into nagilson-uninstall-global
nagilson Aug 13, 2024
d31d537
Merge branch 'main' into nagilson-uninstall-global
nagilson Aug 14, 2024
759e063
fix when extension may have null record
nagilson Aug 14, 2024
30c8dfb
Merge remote-tracking branch 'upstream/main' into nagilson-uninstall-…
nagilson Aug 15, 2024
a1781fc
update changelog
nagilson Aug 15, 2024
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ install.*
.vscode-test/
*.vsix
vscode-dotnet-runtime-library/install scripts/dotnet-install.*
*/images/*
vscode-dotnet-runtime-extension/LICENSE.txt
vscode-dotnet-sdk-extension/LICENSE.txt
.vscode/launch.json
Expand Down
26 changes: 25 additions & 1 deletion vscode-dotnet-runtime-extension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,34 @@ and this project adheres to [Semantic Versioning].

## [2.1.2] - 2024-08-01

Adds the ability to uninstall a particular runtime.
Adds the ability for users to uninstall things themselves.

Adds the ability to uninstall a global installation that is already managed by the extension.

Adds API for extensions to uninstall a singular runtime rather than all runtimes.

Adds offline support so existing installations can be found when offline.

Adds additional signatures to the release.

Fixes 'Lock' acquisition issues.

Fixes a bug with DEBIAN_FRONTEND when installing an SDK on Ubuntu.

Fixes a bug with offline detection.

Fixed a bug with arm64 windows installation detection logic.

Fixed a bug when preview versions are installed by Visual Studio.

Fixes a bug where apt-get lock can be busy. Fixes a bug where stdin can be busy.

Fixes a bug with installation detection of SDKS.

Updates Axios per CVE release.

Migrates to a newer version of typescript and node under the hood. Requires a newer version of VS Code.

Fixes other minor bugs.

## [2.1.1] - 2024-07-18
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion vscode-dotnet-runtime-extension/package-lock.json

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

7 changes: 6 additions & 1 deletion vscode-dotnet-runtime-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": "2.1.2",
"publisher": "ms-dotnettools",
"engines": {
"vscode": "^1.74.0"
"vscode": "^1.81.1"
},
"categories": [
"Other"
Expand Down Expand Up @@ -51,6 +51,11 @@
"title": "Install the .NET SDK System-Wide.",
"category": ".NET Install Tool",
"enablement": "!dotnetAcquisitionExtension.isGlobalSDKUnsupported"
},
{
"command": "dotnet.uninstallPublic",
"title": "Uninstall .NET.",
"category": ".NET Install Tool"
}
],
"configuration": {
Expand Down
100 changes: 91 additions & 9 deletions vscode-dotnet-runtime-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,17 @@ import {
DotnetInstallType,
DotnetAcquisitionTotalSuccessEvent,
isRunningUnderWSL,
InstallRecord,
getMajor,
getMajorMinor,
DotnetOfflineWarning
DotnetOfflineWarning,
} from 'vscode-dotnet-runtime-library';
import { dotnetCoreAcquisitionExtensionId } from './DotnetCoreAcquisitionId';
import { IDotnetCoreAcquisitionWorker } from 'vscode-dotnet-runtime-library/dist/Acquisition/IDotnetCoreAcquisitionWorker';
import { InstallTrackerSingleton } from 'vscode-dotnet-runtime-library/dist/Acquisition/InstallTrackerSingleton';

// tslint:disable no-var-requires
/* tslint:disable:only-arrow-functions */

const packageJson = require('../package.json');

// Extension constants
Expand All @@ -79,11 +82,13 @@ namespace configKeys {
export const existingSharedPath = 'sharedExistingDotnetPath'
export const proxyUrl = 'proxyUrl';
}

namespace commandKeys {
export const acquire = 'acquire';
export const acquireGlobalSDK = 'acquireGlobalSDK';
export const acquireStatus = 'acquireStatus';
export const uninstall = 'uninstall';
export const uninstallPublic = 'uninstallPublic'
export const uninstallAll = 'uninstallAll';
export const listVersions = 'listVersions';
export const recommendedVersion = 'recommendedVersion'
Expand Down Expand Up @@ -307,7 +312,7 @@ export function activate(vsCodeContext: vscode.ExtensionContext, extensionContex
globalEventStream.post(new GlobalAcquisitionContextMenuOpened(`The user has opened the global SDK acquisition context menu.`));

const recommendedVersionResult : IDotnetListVersionsResult = await vscode.commands.executeCommand('dotnet.recommendedVersion');
const recommendedVersion : string = recommendedVersionResult ? recommendedVersionResult[0].version : '';
const recommendedVersion : string = recommendedVersionResult ? recommendedVersionResult[0]?.version : '';

const chosenVersion = await vscode.window.showInputBox(
{
Expand Down Expand Up @@ -354,6 +359,77 @@ export function activate(vsCodeContext: vscode.ExtensionContext, extensionContex
return pathResult;
});

const dotnetUninstallPublicRegistration = vscode.commands.registerCommand(`${commandPrefix}.${commandKeys.uninstallPublic}`, async () =>
{
const existingInstalls = await InstallTrackerSingleton.getInstance(globalEventStream, vsCodeContext.globalState).getExistingInstalls(true);

const menuItems = existingInstalls?.sort(
function(x : InstallRecord, y : InstallRecord) : number
{
if(x.dotnetInstall.installMode === y.dotnetInstall.installMode)
{
return x.dotnetInstall.version.localeCompare(y.dotnetInstall.version);
}
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
}
});

if(menuItems.length < 1)
{
vscode.window.showInformationMessage('No .NET installations were found to uninstall.');
return;
}

const chosenVersion = await vscode.window.showQuickPick(menuItems, { placeHolder: 'Select a version to uninstall.' });

if(chosenVersion)
{
const installRecord : InstallRecord = existingInstalls.find(install => install.dotnetInstall.installId === chosenVersion.internalId)!;

if(!installRecord || !installRecord?.dotnetInstall?.version || !installRecord?.dotnetInstall?.installMode)
{
return;
}

const selectedInstall : DotnetInstall = installRecord.dotnetInstall;
let canContinue = true;
const uninstallWillBreakSomething = !(await InstallTrackerSingleton.getInstance(globalEventStream, vsCodeContext.globalState).canUninstall(true, selectedInstall, true));

const yes = `Continue`;
if(uninstallWillBreakSomething)
{
const pick = await vscode.window.showWarningMessage(
`Uninstalling .NET ${selectedInstall.version} will likely cause ${installRecord.installingExtensions.some(x => x !== null) ? installRecord.installingExtensions.join(', ') : 'extensions such as C# or C# DevKit'} to stop functioning properly. Do you still wish to continue?`, { modal: true }, yes);
canContinue = pick === yes;
}

if(!canContinue)
{
return;
}

const commandContext : IDotnetAcquireContext =
{
version: selectedInstall.version,
mode: selectedInstall.installMode,
installType: selectedInstall.isGlobal ? 'global' : 'local',
architecture: selectedInstall.architecture,
requestingExtensionId : 'user'
}

outputChannel.show(true);
return uninstall(commandContext, true);
}
});

/**
* @returns 0 on success. Error string if not.
*/
Expand All @@ -362,7 +438,7 @@ export function activate(vsCodeContext: vscode.ExtensionContext, extensionContex
return uninstall(commandContext);
});

async function uninstall(commandContext: IDotnetAcquireContext | undefined) : Promise<string>
async function uninstall(commandContext: IDotnetAcquireContext | undefined, force = false) : Promise<string>
{
let result = '1';
await callWithErrorHandling(async () =>
Expand All @@ -378,21 +454,26 @@ export function activate(vsCodeContext: vscode.ExtensionContext, extensionContex
{
const worker = getAcquisitionWorker();
const workerContext = getAcquisitionWorkerContext(commandContext.mode, commandContext);
const versionResolver = new VersionResolver(workerContext);
const resolvedVersion = await versionResolver.getFullVersion(commandContext.version, commandContext.mode);
commandContext.version = resolvedVersion;

if(commandContext.installType === 'local' && !force) // if using force mode, we are also using the UI, which passes the fully specified version to uninstall only
{
const versionResolver = new VersionResolver(workerContext);
const resolvedVersion = await versionResolver.getFullVersion(commandContext.version, commandContext.mode);
commandContext.version = resolvedVersion;
}

const installationId = getInstallIdCustomArchitecture(commandContext.version, commandContext.architecture, commandContext.mode, commandContext.installType);
const install = {installId : installationId, version : commandContext.version, installMode: commandContext.mode, isGlobal: commandContext.installType === 'global',
architecture: commandContext.architecture ?? DotnetCoreAcquisitionWorker.defaultArchitecture()} as DotnetInstall;

if(commandContext.installType === 'local')
{
result = await worker.uninstallLocalRuntimeOrSDK(workerContext, install);
result = await worker.uninstallLocal(workerContext, install, force);
}
else
{
result = await worker.uninstallGlobal(workerContext, install);
const globalInstallerResolver = new GlobalInstallerResolver(workerContext, commandContext.version);
result = await worker.uninstallGlobal(workerContext, install, globalInstallerResolver, force);
}
}
}, getIssueContext(existingPathConfigWorker)(commandContext?.errorConfiguration, 'uninstall'));
Expand Down Expand Up @@ -591,6 +672,7 @@ We will try to install .NET, but are unlikely to be able to connect to the serve
dotnetListVersionsRegistration,
dotnetRecommendedVersionRegistration,
dotnetUninstallRegistration,
dotnetUninstallPublicRegistration,
dotnetUninstallAllRegistration,
showOutputChannelRegistration,
ensureDependenciesRegistration,
Expand Down
22 changes: 12 additions & 10 deletions vscode-dotnet-runtime-library/distro-data/distro-support.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"commandRoot": "apt-get",
"commandParts": [
"-o",
"DPkg::Lock::Timeout=120",
"DPkg::Lock::Timeout=180",
"update"
]
},
Expand All @@ -16,7 +16,7 @@
"commandRoot": "apt-get",
"commandParts": [
"-o",
"DPkg::Lock::Timeout=120",
"DPkg::Lock::Timeout=180",
"install",
"-y",
"{packageName}"
Expand All @@ -29,8 +29,9 @@
"commandRoot": "apt-get",
"commandParts": [
"-o",
"DPkg::Lock::Timeout=120",
"DPkg::Lock::Timeout=180",
"remove",
"-y",
"{packageName}"
]
}
Expand All @@ -41,16 +42,17 @@
"commandRoot": "apt-get",
"commandParts": [
"-o",
"DPkg::Lock::Timeout=120",
"update"
"DPkg::Lock::Timeout=180",
"update",
"-y"
]
},
{
"runUnderSudo": true,
"commandRoot": "apt-get",
"commandParts": [
"-o",
"DPkg::Lock::Timeout=120",
"DPkg::Lock::Timeout=180",
"upgrade",
"-y",
"{packageName}"
Expand All @@ -63,7 +65,7 @@
"commandRoot": "apt-cache",
"commandParts": [
"-o",
"DPkg::Lock::Timeout=120",
"DPkg::Lock::Timeout=180",
"search",
"--names-only",
"^{packageName}$"
Expand Down Expand Up @@ -198,7 +200,7 @@
"commandRoot": "apt-get",
"commandParts": [
"-o",
"DPkg::Lock::Timeout=120",
"DPkg::Lock::Timeout=180",
"install",
"-y",
"wget"
Expand Down Expand Up @@ -226,7 +228,7 @@
"commandRoot": "apt-get",
"commandParts": [
"-o",
"DPkg::Lock::Timeout=120",
"DPkg::Lock::Timeout=180",
"update"
]
}
Expand All @@ -240,7 +242,7 @@
"commandRoot": "apt-get",
"commandParts": [
"-o",
"DPkg::Lock::Timeout=120",
"DPkg::Lock::Timeout=180",
"update"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ EXECFOLDER=$1 # First argument is the working folder as this is launched with cw
TIMEOUT_SEC=$2
OKSIGNALFILE="$EXECFOLDER/ok.txt"
COMMANDTORUNFILE="$EXECFOLDER/command.txt"
EXITFILE="$EXECFOLDER/exit.txt"
#OUTPUTFILE="/home/test_output_.txt"
end=$((SECONDS+3600))

function finish {
rm "$COMMANDTORUNFILE"
rm "$OKSIGNALFILE"
rm -f "$COMMANDTORUNFILE"
rm -f "$OKSIGNALFILE"
}
trap finish EXIT

export DEBIAN_FRONTEND=noninteractive

while true
do
stop=false
Expand Down Expand Up @@ -41,6 +44,10 @@ do
if test -f "$OKSIGNALFILE"; then
rm "$OKSIGNALFILE"
fi
if test -f "$EXITFILE"; then
rm "$EXITFILE"
exit 0
fi
sleep 5
done
done
Loading
Loading