Skip to content

Commit

Permalink
(chocolateyGH-739) Fix: Update templates to use extension
Browse files Browse the repository at this point in the history
Templates are set to use the chocolatey-uninstall.extension helper by default.
The helper includes a catch for invalid registry keys. Using the catch is a
requirement as blindly enumerating will fail every time if even one invalid key
exists.
  • Loading branch information
dtgm committed May 18, 2016
1 parent 56acefa commit c6fb402
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,8 @@ public class ChocolateyUninstallTemplate
}
$uninstalled = $false
$local_key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
$machine_key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*'
$machine_key6432 = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
[array]$key = Get-ItemProperty -Path @($machine_key6432,$machine_key, $local_key) `
-ErrorAction SilentlyContinue `
| ? { $_.DisplayName -like ""$softwareName"" }
# Get-UninstallRegistryKey is provided by the chocolatey extension package "chocolatey-uninstall.extension" and must be included as a dependency in this package's nuspec if used.
[array]$key = Get-UninstallRegistryKey -SoftwareName $softwareName

if ($key.Count -eq 1) {
$key | % {
Expand Down
2 changes: 2 additions & 0 deletions src/chocolatey/infrastructure.app/templates/NuspecTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public class NuspecTemplate
<dependency id="""" version=""[_MIN_VERSION_INCLUSIVE, MAX_VERSION_INCLUSIVE]"" />
<dependency id="""" version=""[_MIN_VERSION_INCLUSIVE, MAX_VERSION_EXCLUSIVE)"" />
<dependency id="""" />
<!-- If including a chocolateyUninstall.ps1 file to uninstall an EXE/MSI or similar installable program, you most likely will require the chocolatey-uninstall.extension package. Please verify whether you are using a helper function from that package. -->
<dependency id=""chocolatey-uninstall.extension"" />
</dependencies>-->
<!--<provides>NOT YET IMPLEMENTED</provides>-->
Expand Down

0 comments on commit c6fb402

Please sign in to comment.