Skip to content

Commit 13e2ebe

Browse files
authored
Merge pull request #372 from pauby/fix-uninstall-leftover-shortcut
(GH-336) Fix uninstall leftover shortcut
2 parents 9596ea3 + 312abb1 commit 13e2ebe

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

BuildScripts/chocolateyUninstall.ps1

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
$tools = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
2+
. (Join-Path -Path $tools -ChildPath 'Setup.ps1')
3+
4+
try {
5+
$ModuleName = (Get-ChildItem $tools | Where-Object { $_.PSIsContainer }).BaseName
6+
Uninstall-Boxstarter $tools $ModuleName $env:chocolateyPackageParameters
7+
}
8+
catch {
9+
Write-Output $_ | Format-List * -force
10+
throw $_.Exception
11+
}

BuildScripts/default.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ task Copy-PowerShellFiles -depends Clean-Artifacts {
272272
$exclude = @("bin", "obj", "*.pssproj")
273273

274274
Copy-Item -Path $basedir\BuildScripts\chocolateyinstall.ps1 -Destination $tempNuGetDirectory
275+
Copy-Item -Path $basedir\BuildScripts\chocolateyUninstall.ps1 -Destination $tempNuGetDirectory
275276
Copy-Item -Path $basedir\BuildScripts\setup.ps1 -Destination $tempNuGetDirectory
276277
Copy-Item -Path $basedir\BuildScripts\nuget\Boxstarter.Azure.PreInstall.ps1 -Destination $tempNuGetDirectory
277278
Copy-Item -Path $basedir\BuildScripts\BoxstarterChocolateyInstall.ps1 -Destination $tempNuGetDirectory

BuildScripts/nuget/Boxstarter.Chocolatey.nuspec

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
</metadata>
3030
<files>
3131
<file src="..\..\buildArtifacts\tempNuGetFolders\chocolateyinstall.ps1" target="tools" />
32+
<file src="..\..\buildArtifacts\tempNuGetFolders\chocolateyUninstall.ps1" target="tools" />
3233
<file src="..\..\buildArtifacts\tempNuGetFolders\Setup.ps1" target="tools" />
3334
<file src="..\..\boxstarter.bat" target="tools" />
3435
<file src="..\..\boxstarter.config" target="tools" />

BuildScripts/setup.ps1

+18
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,24 @@ PS:>Get-Help Boxstarter
6262
}
6363
}
6464

65+
function Uninstall-Boxstarter ($here, $ModuleName, $installArgs = "") {
66+
67+
if ($ModuleName -eq "Boxstarter.Chocolatey" -and !$env:appdata.StartsWith($env:windir)) {
68+
$startMenu = Join-Path -Path ([Environment]::GetFolderPath('CommonPrograms')) -ChildPath "Boxstarter"
69+
70+
if (Test-Path $startMenu) {
71+
Write-Verbose "Removing '$startMenu' menu folder"
72+
Remove-Item -Path $startMenu -Recurse -Force
73+
}
74+
75+
$desktopShortcut = Join-Path -Path ([Environment]::GetFolderPath('CommonDesktop')) -ChildPath "Boxstarter Shell.lnk"
76+
if (Test-Path $desktopShortcut) {
77+
Write-Verbose "Removing '$desktopShortcut'"
78+
Remove-Item -Path $desktopShortcut -Force
79+
}
80+
}
81+
}
82+
6583
function Create-Shortcut($location, $target, $targetArgs, $boxstarterPath) {
6684
$wshshell = New-Object -ComObject WScript.Shell
6785
$lnk = $wshshell.CreateShortcut($location)

0 commit comments

Comments
 (0)