From 77840a2e94cde7ffea6fd37594dde20aad81a8a7 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 10:04:59 -0600 Subject: [PATCH 01/37] Search by package ID if name and version specified --- CHANGELOG.md | 4 ++++ Test/ChocolateyGet.tests.ps1 | 4 ++-- src/ChocolateyGet.psd1 | 2 +- src/private/Invoke-Choco.ps1 | 8 ++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60b1688..0ce29e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.1.0] - 2021-01-23 +#### Changed +* Search repository by exact package name if both package name and required version are specified (#20) + ## [2.0.0] - 2020-10-05 #### Added * Searching/installing/managing multiple Chocolatey sources (#5) diff --git a/Test/ChocolateyGet.tests.ps1 b/Test/ChocolateyGet.tests.ps1 index 6fa9a61..2f8f38c 100644 --- a/Test/ChocolateyGet.tests.ps1 +++ b/Test/ChocolateyGet.tests.ps1 @@ -129,8 +129,8 @@ Describe "$platform multi-source support" { } Describe "$platform version filters" { - $package = 'cpu-z' - $version = '1.87' + $package = 'ninja' + $version = '1.10.2' AfterAll { Uninstall-Package -Name $package -Provider $ChocolateyGet -ErrorAction SilentlyContinue diff --git a/src/ChocolateyGet.psd1 b/src/ChocolateyGet.psd1 index 2f72a9a..c4ccd9f 100644 --- a/src/ChocolateyGet.psd1 +++ b/src/ChocolateyGet.psd1 @@ -1,6 +1,6 @@ @{ RootModule = 'ChocolateyGet.psm1' - ModuleVersion = '2.0.0' + ModuleVersion = '2.1.0' GUID = 'c1735ed7-8b2f-426a-8cbc-b7feb6b8288d' Author = 'Jianyun' Copyright = '' diff --git a/src/private/Invoke-Choco.ps1 b/src/private/Invoke-Choco.ps1 index 412497e..6cc9203 100644 --- a/src/private/Invoke-Choco.ps1 +++ b/src/private/Invoke-Choco.ps1 @@ -115,6 +115,10 @@ function Invoke-Choco { Invoke-Command $genericParams if ($Package) { $config.Input = $Package + if ($Version) { + # Limit NuGet API result set to just the specific package name if version is specified + $config.ListCommand.ByIdOnly = $true + } } $config.CommandName = [chocolatey.infrastructure.app.domain.CommandNameType]::list }) | Out-Null @@ -263,6 +267,10 @@ function Invoke-Choco { if ($Version) { $cmdString += "--version $Version " + if ($Package) { + # Limit NuGet API result set to just the specific package name if version is specified + $cmdString += "--exact " + } } if ($SourceName) { From a7f0097762684a6d6e74271cd8bb5b5c3e53fbf7 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 10:29:05 -0600 Subject: [PATCH 02/37] Should have used Exact in the ListCommand config --- src/private/Invoke-Choco.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/private/Invoke-Choco.ps1 b/src/private/Invoke-Choco.ps1 index 6cc9203..6dceb5b 100644 --- a/src/private/Invoke-Choco.ps1 +++ b/src/private/Invoke-Choco.ps1 @@ -117,7 +117,7 @@ function Invoke-Choco { $config.Input = $Package if ($Version) { # Limit NuGet API result set to just the specific package name if version is specified - $config.ListCommand.ByIdOnly = $true + $config.ListCommand.Exact = $true } } $config.CommandName = [chocolatey.infrastructure.app.domain.CommandNameType]::list From 8150cf4fde291a5e1dc29dd9049ac44e9f195fff Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 10:43:38 -0600 Subject: [PATCH 03/37] Also use 'exact' for other version queries --- src/private/Invoke-Choco.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/private/Invoke-Choco.ps1 b/src/private/Invoke-Choco.ps1 index 6dceb5b..8e9623f 100644 --- a/src/private/Invoke-Choco.ps1 +++ b/src/private/Invoke-Choco.ps1 @@ -115,7 +115,7 @@ function Invoke-Choco { Invoke-Command $genericParams if ($Package) { $config.Input = $Package - if ($Version) { + if ($Version -or $AllVersions) { # Limit NuGet API result set to just the specific package name if version is specified $config.ListCommand.Exact = $true } @@ -263,14 +263,14 @@ function Invoke-Choco { if ($Package) { $cmdString += "$Package " + if ($Version -or $AllVersions) { + # Limit NuGet API result set to just the specific package name if version is specified + $cmdString += "--exact " + } } if ($Version) { $cmdString += "--version $Version " - if ($Package) { - # Limit NuGet API result set to just the specific package name if version is specified - $cmdString += "--exact " - } } if ($SourceName) { From 01c58b3b5ed66027f820031d4b81adb2eb55f887 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 10:49:51 -0600 Subject: [PATCH 04/37] Keep version test one version back from latest --- Test/ChocolateyGet.tests.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Test/ChocolateyGet.tests.ps1 b/Test/ChocolateyGet.tests.ps1 index 2f8f38c..4439cf0 100644 --- a/Test/ChocolateyGet.tests.ps1 +++ b/Test/ChocolateyGet.tests.ps1 @@ -130,7 +130,8 @@ Describe "$platform multi-source support" { Describe "$platform version filters" { $package = 'ninja' - $version = '1.10.2' + # Keep at least one version back, to test the 'latest' feature + $version = '1.10.1' AfterAll { Uninstall-Package -Name $package -Provider $ChocolateyGet -ErrorAction SilentlyContinue From 050c634678ec58db0ef5d87f7e70587a1f6c1bc3 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 11:14:28 -0600 Subject: [PATCH 05/37] Downgrade choco for exact package version search --- paket.lock | 2 +- src/private/Invoke-Choco.ps1 | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/paket.lock b/paket.lock index 50f59db..4276f1c 100644 --- a/paket.lock +++ b/paket.lock @@ -1,5 +1,5 @@ NUGET remote: https://api.nuget.org/v3/index.json - chocolatey.lib (0.10.15) + chocolatey.lib (0.10.13) log4net (>= 2.0.3) log4net (2.0.3) diff --git a/src/private/Invoke-Choco.ps1 b/src/private/Invoke-Choco.ps1 index 8e9623f..e9ce6c3 100644 --- a/src/private/Invoke-Choco.ps1 +++ b/src/private/Invoke-Choco.ps1 @@ -117,6 +117,7 @@ function Invoke-Choco { $config.Input = $Package if ($Version -or $AllVersions) { # Limit NuGet API result set to just the specific package name if version is specified + # Have to keep choco pinned to 0.10.13 due to https://github.com/chocolatey/choco/issues/1843 - should be fixed in 0.10.16, which is still in beta $config.ListCommand.Exact = $true } } @@ -263,8 +264,9 @@ function Invoke-Choco { if ($Package) { $cmdString += "$Package " - if ($Version -or $AllVersions) { + if ($Version -or $AllVersions) { # Limit NuGet API result set to just the specific package name if version is specified + # Have to keep choco pinned to 0.10.13 due to https://github.com/chocolatey/choco/issues/1843 - should be fixed in 0.10.16, which is still in beta $cmdString += "--exact " } } From 74f24393240489efdb7558c579741e37519d4a42 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 11:27:15 -0600 Subject: [PATCH 06/37] Downgrade choco CLI install and update change log --- CHANGELOG.md | 1 + src/private/Install-ChocoBinaries.ps1 | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ce29e0..4b0f003 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2.1.0] - 2021-01-23 #### Changed * Search repository by exact package name if both package name and required version are specified (#20) + * Requires downgrading the version of Chocolatey to 0.10.13 due to [a Chocolatey defect](https://github.com/chocolatey/choco/issues/1843) until 0.10.16 is released ## [2.0.0] - 2020-10-05 #### Added diff --git a/src/private/Install-ChocoBinaries.ps1 b/src/private/Install-ChocoBinaries.ps1 index 46d7064..d2a5354 100644 --- a/src/private/Install-ChocoBinaries.ps1 +++ b/src/private/Install-ChocoBinaries.ps1 @@ -25,7 +25,9 @@ function Install-ChocoBinaries { if (-not ([Net.ServicePointManager]::SecurityProtocol -eq [Net.SecurityProtocolType]::SystemDefault)) { [Net.ServicePointManager]::SecurityProtocol = ([Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12) } - + # Have to keep choco pinned to 0.10.13 due to https://github.com/chocolatey/choco/issues/1843 - should be fixed in 0.10.16, which is still in beta + # https://docs.chocolatey.org/en-us/choco/setup#installing-a-particular-version-of-chocolatey + $env:chocolateyVersion = '0.10.13' Invoke-WebRequest 'https://chocolatey.org/install.ps1' -UseBasicParsing | Invoke-Expression > $null } catch { ThrowError -ExceptionName 'System.OperationCanceledException' ` From 6559b16ea6c617fbe241c0718ad125140b4fc2ce Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 11:30:34 -0600 Subject: [PATCH 07/37] Test what's wrong with the appveyor job --- Test/ChocolateyGet.tests.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Test/ChocolateyGet.tests.ps1 b/Test/ChocolateyGet.tests.ps1 index 4439cf0..69beaed 100644 --- a/Test/ChocolateyGet.tests.ps1 +++ b/Test/ChocolateyGet.tests.ps1 @@ -57,16 +57,16 @@ Describe "$platform DSC-compliant package installation and uninstallation" { $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' It 'searches for the latest version of a package' { - Find-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Find-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'silently installs the latest version of a package' { - Install-Package -Force -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Install-Package -Force -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'finds the locally installed package just installed' { - Get-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Get-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'silently uninstalls the locally installed package just installed' { - Uninstall-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Uninstall-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } } } @@ -87,11 +87,11 @@ Describe "$platform pipline-based package installation and uninstallation" { $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' It 'searches for and silently installs the latest version of a package' { - Find-Package -Provider $ChocolateyGet -Name $package | Install-Package -Force -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Find-Package -Provider $ChocolateyGet -Name $package -Verbose | Install-Package -Force -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'finds and silently uninstalls the locally installed package just installed' { - Get-Package -Provider $ChocolateyGet -Name $package | Uninstall-Package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Get-Package -Provider $ChocolateyGet -Name $package -Verbose | Uninstall-Package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } } } From d6d47da76b208c60ca81b87bb0f1dfa85d096705 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 11:42:09 -0600 Subject: [PATCH 08/37] Checking to see if appveyor broke the build --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 3aa007c..b30966e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,6 @@ version: 1.0.{build} -image: Visual Studio 2019 +image: Previous Visual Studio 2019 install: - dotnet tool restore From 85242a448c33272506dec4346e61edf7d5df1770 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 11:42:26 -0600 Subject: [PATCH 09/37] Revert "Test what's wrong with the appveyor job" This reverts commit 6559b16ea6c617fbe241c0718ad125140b4fc2ce. --- Test/ChocolateyGet.tests.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Test/ChocolateyGet.tests.ps1 b/Test/ChocolateyGet.tests.ps1 index 69beaed..4439cf0 100644 --- a/Test/ChocolateyGet.tests.ps1 +++ b/Test/ChocolateyGet.tests.ps1 @@ -57,16 +57,16 @@ Describe "$platform DSC-compliant package installation and uninstallation" { $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' It 'searches for the latest version of a package' { - Find-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Find-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'silently installs the latest version of a package' { - Install-Package -Force -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Install-Package -Force -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'finds the locally installed package just installed' { - Get-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Get-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'silently uninstalls the locally installed package just installed' { - Uninstall-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Uninstall-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } } } @@ -87,11 +87,11 @@ Describe "$platform pipline-based package installation and uninstallation" { $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' It 'searches for and silently installs the latest version of a package' { - Find-Package -Provider $ChocolateyGet -Name $package -Verbose | Install-Package -Force -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Find-Package -Provider $ChocolateyGet -Name $package | Install-Package -Force -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'finds and silently uninstalls the locally installed package just installed' { - Get-Package -Provider $ChocolateyGet -Name $package -Verbose | Uninstall-Package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Get-Package -Provider $ChocolateyGet -Name $package | Uninstall-Package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } } } From a655f2417be3e49559b1e135de4a2333b89b3448 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 11:51:40 -0600 Subject: [PATCH 10/37] Possible case sensitivity issue --- Test/ChocolateyGet.tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Test/ChocolateyGet.tests.ps1 b/Test/ChocolateyGet.tests.ps1 index 4439cf0..02eecad 100644 --- a/Test/ChocolateyGet.tests.ps1 +++ b/Test/ChocolateyGet.tests.ps1 @@ -117,7 +117,7 @@ Describe "$platform multi-source support" { Register-PackageSource -Name $altSourceName -Provider $ChocolateyGet -Location $altSourceLocation | Where-Object {$_.Name -eq $altSourceName} | Should Not BeNullOrEmpty } It 'searches for and installs the latest version of a package from an alternate source' { - Find-Package -Provider $ChocolateyGet -Name $package -source $altSourceName | Install-Package -Force | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Find-Package -Provider $ChocolateyGet -Name $package -Source $altSourceName | Install-Package -Force | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'finds and uninstalls a package installed from an alternate source' { Get-Package -Provider $ChocolateyGet -Name $package | Uninstall-Package | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty From c2e2ebef4c076992700ddd1564149b256473b709 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 11:55:03 -0600 Subject: [PATCH 11/37] Remove extra verbose line --- src/private/Find-ChocoPackage.ps1 | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/private/Find-ChocoPackage.ps1 b/src/private/Find-ChocoPackage.ps1 index 6f6ee28..ad95ece 100644 --- a/src/private/Find-ChocoPackage.ps1 +++ b/src/private/Find-ChocoPackage.ps1 @@ -25,8 +25,6 @@ function Find-ChocoPackage { [array]$RegisteredPackageSources = Get-PackageSources if ($options -and $options.ContainsKey('Source')) { - # Finding the matched package sources from the registered ones - Write-Verbose ($LocalizedData.SpecifiedSourceName -f ($options['Source'])) if ($RegisteredPackageSources.Name -eq $options['Source']) { # Found the matched registered source $selectedSource = $options['Source'] From 1c0fd7aa7bd05b494e1fad1ea0a1265d0db9754e Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 11:58:22 -0600 Subject: [PATCH 12/37] Revert "Remove extra verbose line" This reverts commit c2e2ebef4c076992700ddd1564149b256473b709. --- src/private/Find-ChocoPackage.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/private/Find-ChocoPackage.ps1 b/src/private/Find-ChocoPackage.ps1 index ad95ece..6f6ee28 100644 --- a/src/private/Find-ChocoPackage.ps1 +++ b/src/private/Find-ChocoPackage.ps1 @@ -25,6 +25,8 @@ function Find-ChocoPackage { [array]$RegisteredPackageSources = Get-PackageSources if ($options -and $options.ContainsKey('Source')) { + # Finding the matched package sources from the registered ones + Write-Verbose ($LocalizedData.SpecifiedSourceName -f ($options['Source'])) if ($RegisteredPackageSources.Name -eq $options['Source']) { # Found the matched registered source $selectedSource = $options['Source'] From 78461eed3bce9e14d630caeec9d9f34cacf37515 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 11:58:52 -0600 Subject: [PATCH 13/37] Revert "Possible case sensitivity issue" This reverts commit a655f2417be3e49559b1e135de4a2333b89b3448. --- Test/ChocolateyGet.tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Test/ChocolateyGet.tests.ps1 b/Test/ChocolateyGet.tests.ps1 index 02eecad..4439cf0 100644 --- a/Test/ChocolateyGet.tests.ps1 +++ b/Test/ChocolateyGet.tests.ps1 @@ -117,7 +117,7 @@ Describe "$platform multi-source support" { Register-PackageSource -Name $altSourceName -Provider $ChocolateyGet -Location $altSourceLocation | Where-Object {$_.Name -eq $altSourceName} | Should Not BeNullOrEmpty } It 'searches for and installs the latest version of a package from an alternate source' { - Find-Package -Provider $ChocolateyGet -Name $package -Source $altSourceName | Install-Package -Force | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Find-Package -Provider $ChocolateyGet -Name $package -source $altSourceName | Install-Package -Force | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'finds and uninstalls a package installed from an alternate source' { Get-Package -Provider $ChocolateyGet -Name $package | Uninstall-Package | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty From f9df540b03bc0b373ba2a26fe2037f321c262330 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 12:06:28 -0600 Subject: [PATCH 14/37] Testing of sysinternals broke the pipeline --- Test/ChocolateyGet.tests.ps1 | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Test/ChocolateyGet.tests.ps1 b/Test/ChocolateyGet.tests.ps1 index 4439cf0..e02c599 100644 --- a/Test/ChocolateyGet.tests.ps1 +++ b/Test/ChocolateyGet.tests.ps1 @@ -26,11 +26,12 @@ Describe "$platform basic package search operations" { } } Context 'with additional arguments' { - $package = 'cpu-z' - $argsAndParams = '--exact' + $package = 'sysinternals' + $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' + $version = '2020.11.25' It 'searches for the exact package name' { - Find-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Should Not BeNullOrEmpty + Find-Package -Provider $ChocolateyGet -Name $package -RequiredVersion $version -AdditionalArguments $argsAndParams | Should Not BeNullOrEmpty } } } @@ -57,16 +58,16 @@ Describe "$platform DSC-compliant package installation and uninstallation" { $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' It 'searches for the latest version of a package' { - Find-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Find-Package -Provider $ChocolateyGet -Name $package -RequiredVersion $version -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'silently installs the latest version of a package' { - Install-Package -Force -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Install-Package -Force -Provider $ChocolateyGet -Name $package -RequiredVersion $version -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'finds the locally installed package just installed' { - Get-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Get-Package -Provider $ChocolateyGet -Name $package -RequiredVersion $version -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'silently uninstalls the locally installed package just installed' { - Uninstall-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Uninstall-Package -Provider $ChocolateyGet -Name $package -RequiredVersion $version -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } } } @@ -87,11 +88,11 @@ Describe "$platform pipline-based package installation and uninstallation" { $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' It 'searches for and silently installs the latest version of a package' { - Find-Package -Provider $ChocolateyGet -Name $package | Install-Package -Force -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Find-Package -Provider $ChocolateyGet -RequiredVersion $version -Name $package | Install-Package -Force -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'finds and silently uninstalls the locally installed package just installed' { - Get-Package -Provider $ChocolateyGet -Name $package | Uninstall-Package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Get-Package -Provider $ChocolateyGet -RequiredVersion $version -Name $package | Uninstall-Package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } } } From 65ded1b5639367999fd75d485e53168b7fe7008c Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 12:10:43 -0600 Subject: [PATCH 15/37] Forgot to include version in all the tests --- Test/ChocolateyGet.tests.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Test/ChocolateyGet.tests.ps1 b/Test/ChocolateyGet.tests.ps1 index e02c599..c7a1a4d 100644 --- a/Test/ChocolateyGet.tests.ps1 +++ b/Test/ChocolateyGet.tests.ps1 @@ -56,6 +56,7 @@ Describe "$platform DSC-compliant package installation and uninstallation" { Context 'with additional arguments' { $package = 'sysinternals' $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' + $version = '2020.11.25' It 'searches for the latest version of a package' { Find-Package -Provider $ChocolateyGet -Name $package -RequiredVersion $version -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty @@ -86,6 +87,7 @@ Describe "$platform pipline-based package installation and uninstallation" { Context 'with additional arguments' { $package = 'sysinternals' $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' + $version = '2020.11.25' It 'searches for and silently installs the latest version of a package' { Find-Package -Provider $ChocolateyGet -RequiredVersion $version -Name $package | Install-Package -Force -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty From 857f5c9db7b8fe51638b27f6f66395d1bc84ed96 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 12:15:00 -0600 Subject: [PATCH 16/37] Revert "Checking to see if appveyor broke the build" This reverts commit d6d47da76b208c60ca81b87bb0f1dfa85d096705. --- Test/ChocolateyGet.tests.ps1 | 21 +++++++++------------ appveyor.yml | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Test/ChocolateyGet.tests.ps1 b/Test/ChocolateyGet.tests.ps1 index c7a1a4d..69beaed 100644 --- a/Test/ChocolateyGet.tests.ps1 +++ b/Test/ChocolateyGet.tests.ps1 @@ -26,12 +26,11 @@ Describe "$platform basic package search operations" { } } Context 'with additional arguments' { - $package = 'sysinternals' - $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' - $version = '2020.11.25' + $package = 'cpu-z' + $argsAndParams = '--exact' It 'searches for the exact package name' { - Find-Package -Provider $ChocolateyGet -Name $package -RequiredVersion $version -AdditionalArguments $argsAndParams | Should Not BeNullOrEmpty + Find-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Should Not BeNullOrEmpty } } } @@ -56,19 +55,18 @@ Describe "$platform DSC-compliant package installation and uninstallation" { Context 'with additional arguments' { $package = 'sysinternals' $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' - $version = '2020.11.25' It 'searches for the latest version of a package' { - Find-Package -Provider $ChocolateyGet -Name $package -RequiredVersion $version -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Find-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'silently installs the latest version of a package' { - Install-Package -Force -Provider $ChocolateyGet -Name $package -RequiredVersion $version -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Install-Package -Force -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'finds the locally installed package just installed' { - Get-Package -Provider $ChocolateyGet -Name $package -RequiredVersion $version -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Get-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'silently uninstalls the locally installed package just installed' { - Uninstall-Package -Provider $ChocolateyGet -Name $package -RequiredVersion $version -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Uninstall-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } } } @@ -87,14 +85,13 @@ Describe "$platform pipline-based package installation and uninstallation" { Context 'with additional arguments' { $package = 'sysinternals' $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' - $version = '2020.11.25' It 'searches for and silently installs the latest version of a package' { - Find-Package -Provider $ChocolateyGet -RequiredVersion $version -Name $package | Install-Package -Force -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Find-Package -Provider $ChocolateyGet -Name $package -Verbose | Install-Package -Force -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'finds and silently uninstalls the locally installed package just installed' { - Get-Package -Provider $ChocolateyGet -RequiredVersion $version -Name $package | Uninstall-Package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Get-Package -Provider $ChocolateyGet -Name $package -Verbose | Uninstall-Package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } } } diff --git a/appveyor.yml b/appveyor.yml index b30966e..3aa007c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,6 @@ version: 1.0.{build} -image: Previous Visual Studio 2019 +image: Visual Studio 2019 install: - dotnet tool restore From 50528d8c63a09be947812be9cb13d5800e3a3d46 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 12:15:44 -0600 Subject: [PATCH 17/37] Testing in appveyor without params and args --- Test/ChocolateyGet.tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Test/ChocolateyGet.tests.ps1 b/Test/ChocolateyGet.tests.ps1 index 69beaed..20e381e 100644 --- a/Test/ChocolateyGet.tests.ps1 +++ b/Test/ChocolateyGet.tests.ps1 @@ -54,7 +54,7 @@ Describe "$platform DSC-compliant package installation and uninstallation" { } Context 'with additional arguments' { $package = 'sysinternals' - $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' + # $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' It 'searches for the latest version of a package' { Find-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty @@ -84,7 +84,7 @@ Describe "$platform pipline-based package installation and uninstallation" { } Context 'with additional arguments' { $package = 'sysinternals' - $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' + # $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' It 'searches for and silently installs the latest version of a package' { Find-Package -Provider $ChocolateyGet -Name $package -Verbose | Install-Package -Force -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty From 890b0b5fcb4580538879c19d2c0fe3c29f6edf39 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 12:18:12 -0600 Subject: [PATCH 18/37] More appveyor tests --- Test/ChocolateyGet.tests.ps1 | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Test/ChocolateyGet.tests.ps1 b/Test/ChocolateyGet.tests.ps1 index 20e381e..7a38747 100644 --- a/Test/ChocolateyGet.tests.ps1 +++ b/Test/ChocolateyGet.tests.ps1 @@ -30,7 +30,7 @@ Describe "$platform basic package search operations" { $argsAndParams = '--exact' It 'searches for the exact package name' { - Find-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Should Not BeNullOrEmpty + Find-Package -Provider $ChocolateyGet -Name $package | Should Not BeNullOrEmpty } } } @@ -54,19 +54,18 @@ Describe "$platform DSC-compliant package installation and uninstallation" { } Context 'with additional arguments' { $package = 'sysinternals' - # $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' It 'searches for the latest version of a package' { - Find-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Find-Package -Provider $ChocolateyGet -Name $package -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'silently installs the latest version of a package' { - Install-Package -Force -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Install-Package -Force -Provider $ChocolateyGet -Name $package -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'finds the locally installed package just installed' { - Get-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Get-Package -Provider $ChocolateyGet -Name $package -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'silently uninstalls the locally installed package just installed' { - Uninstall-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Uninstall-Package -Provider $ChocolateyGet -Name $package -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } } } @@ -84,14 +83,13 @@ Describe "$platform pipline-based package installation and uninstallation" { } Context 'with additional arguments' { $package = 'sysinternals' - # $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' It 'searches for and silently installs the latest version of a package' { - Find-Package -Provider $ChocolateyGet -Name $package -Verbose | Install-Package -Force -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Find-Package -Provider $ChocolateyGet -Name $package -Verbose | Install-Package -Force -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'finds and silently uninstalls the locally installed package just installed' { - Get-Package -Provider $ChocolateyGet -Name $package -Verbose | Uninstall-Package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Get-Package -Provider $ChocolateyGet -Name $package -Verbose | Uninstall-Package -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } } } From 2da3f6ce8afe74ce91296821a6fec284ed4985ad Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 12:21:00 -0600 Subject: [PATCH 19/37] Revert "More appveyor tests" This reverts commit 890b0b5fcb4580538879c19d2c0fe3c29f6edf39. --- Test/ChocolateyGet.tests.ps1 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Test/ChocolateyGet.tests.ps1 b/Test/ChocolateyGet.tests.ps1 index 7a38747..20e381e 100644 --- a/Test/ChocolateyGet.tests.ps1 +++ b/Test/ChocolateyGet.tests.ps1 @@ -30,7 +30,7 @@ Describe "$platform basic package search operations" { $argsAndParams = '--exact' It 'searches for the exact package name' { - Find-Package -Provider $ChocolateyGet -Name $package | Should Not BeNullOrEmpty + Find-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Should Not BeNullOrEmpty } } } @@ -54,18 +54,19 @@ Describe "$platform DSC-compliant package installation and uninstallation" { } Context 'with additional arguments' { $package = 'sysinternals' + # $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' It 'searches for the latest version of a package' { - Find-Package -Provider $ChocolateyGet -Name $package -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Find-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'silently installs the latest version of a package' { - Install-Package -Force -Provider $ChocolateyGet -Name $package -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Install-Package -Force -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'finds the locally installed package just installed' { - Get-Package -Provider $ChocolateyGet -Name $package -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Get-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'silently uninstalls the locally installed package just installed' { - Uninstall-Package -Provider $ChocolateyGet -Name $package -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Uninstall-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } } } @@ -83,13 +84,14 @@ Describe "$platform pipline-based package installation and uninstallation" { } Context 'with additional arguments' { $package = 'sysinternals' + # $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' It 'searches for and silently installs the latest version of a package' { - Find-Package -Provider $ChocolateyGet -Name $package -Verbose | Install-Package -Force -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Find-Package -Provider $ChocolateyGet -Name $package -Verbose | Install-Package -Force -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'finds and silently uninstalls the locally installed package just installed' { - Get-Package -Provider $ChocolateyGet -Name $package -Verbose | Uninstall-Package -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Get-Package -Provider $ChocolateyGet -Name $package -Verbose | Uninstall-Package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } } } From fa39f028f4876b19846562492da43b5c88e2ad7b Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 12:21:40 -0600 Subject: [PATCH 20/37] Revert "Testing in appveyor without params and args" This reverts commit 50528d8c63a09be947812be9cb13d5800e3a3d46. --- Test/ChocolateyGet.tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Test/ChocolateyGet.tests.ps1 b/Test/ChocolateyGet.tests.ps1 index 20e381e..69beaed 100644 --- a/Test/ChocolateyGet.tests.ps1 +++ b/Test/ChocolateyGet.tests.ps1 @@ -54,7 +54,7 @@ Describe "$platform DSC-compliant package installation and uninstallation" { } Context 'with additional arguments' { $package = 'sysinternals' - # $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' + $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' It 'searches for the latest version of a package' { Find-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty @@ -84,7 +84,7 @@ Describe "$platform pipline-based package installation and uninstallation" { } Context 'with additional arguments' { $package = 'sysinternals' - # $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' + $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' It 'searches for and silently installs the latest version of a package' { Find-Package -Provider $ChocolateyGet -Name $package -Verbose | Install-Package -Force -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty From d1e41ef757400a4684a4a3d95be26c35ed05b7a2 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 12:25:12 -0600 Subject: [PATCH 21/37] Trying a less privileged path --- Test/ChocolateyGet.tests.ps1 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Test/ChocolateyGet.tests.ps1 b/Test/ChocolateyGet.tests.ps1 index 69beaed..0b71b76 100644 --- a/Test/ChocolateyGet.tests.ps1 +++ b/Test/ChocolateyGet.tests.ps1 @@ -54,19 +54,19 @@ Describe "$platform DSC-compliant package installation and uninstallation" { } Context 'with additional arguments' { $package = 'sysinternals' - $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' + $argsAndParams = '--paramsglobal --params "/InstallDir='+$env:TEMP+'\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' It 'searches for the latest version of a package' { - Find-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Find-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'silently installs the latest version of a package' { - Install-Package -Force -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Install-Package -Force -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'finds the locally installed package just installed' { - Get-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Get-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'silently uninstalls the locally installed package just installed' { - Uninstall-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Uninstall-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } } } @@ -84,14 +84,14 @@ Describe "$platform pipline-based package installation and uninstallation" { } Context 'with additional arguments' { $package = 'sysinternals' - $argsAndParams = '--paramsglobal --params "/InstallDir=c:\windows\temp\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' + $argsAndParams = '--paramsglobal --params "/InstallDir='+$env:TEMP+'\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false' It 'searches for and silently installs the latest version of a package' { - Find-Package -Provider $ChocolateyGet -Name $package -Verbose | Install-Package -Force -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Find-Package -Provider $ChocolateyGet -Name $package | Install-Package -Force -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } It 'finds and silently uninstalls the locally installed package just installed' { - Get-Package -Provider $ChocolateyGet -Name $package -Verbose | Uninstall-Package -AdditionalArguments $argsAndParams -Verbose | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty + Get-Package -Provider $ChocolateyGet -Name $package | Uninstall-Package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty } } } From ba27ab8ca515099c042805354829eaa3ac6def53 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 12:30:42 -0600 Subject: [PATCH 22/37] Downgrade choco in appveyor - exact search bug --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index 3aa007c..744549d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -17,6 +17,7 @@ build_script: test_script: - ps: Invoke-Pester -EnableExit -OutputFormat NUnitXml -OutputFile TestsResults.NativeAPI.xml - ps: (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\TestsResults.NativeAPI.xml)) + - pwsh: choco install chocolatey -y --version 0.10.13 --allow-downgrade - pwsh: Invoke-Pester -EnableExit -OutputFormat NUnitXml -OutputFile TestsResults.CLI.xml - pwsh: (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\TestsResults.CLI.xml)) From ac38d424dd69167626773c33741d336c4ad34961 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 13:06:52 -0600 Subject: [PATCH 23/37] Finish Chocolatey downgrade documentation --- CHANGELOG.md | 4 ++-- README.md | 22 ++++++++++++++++++++++ appveyor.yml | 2 +- src/private/Invoke-Choco.ps1 | 4 ++-- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b0f003..688f559 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2.1.0] - 2021-01-23 #### Changed -* Search repository by exact package name if both package name and required version are specified (#20) - * Requires downgrading the version of Chocolatey to 0.10.13 due to [a Chocolatey defect](https://github.com/chocolatey/choco/issues/1843) until 0.10.16 is released +* Change default search to use exact package name if both package name and required version are specified (#20) + * Requires downgrade to Chocolatey 0.10.13 due to [a Chocolatey defect](https://github.com/chocolatey/choco/issues/1843) until 0.10.16 is released ## [2.0.0] - 2020-10-05 #### Added diff --git a/README.md b/README.md index f4e10e0..3ccd5b4 100644 --- a/README.md +++ b/README.md @@ -191,5 +191,27 @@ When used with CoreCLR, PowerShell 7.0.1 is a minimum requirement due to [a comp ### Save a package Save-Package is not supported with the ChocolateyGet provider, due to Chocolatey not supporting package downloads without special licensing. +### CLI Package search with MinimumVersion / MaximumVersion / AllVersions doesn't work +Due to [a bug with Chocolatey](https://github.com/chocolatey/choco/issues/1843) versions 0.10.14 through 0.10.15, ChocolateyGet is unable to search packages by package range via command line as of version 2.1.0. + +Until [Chocolatey 0.10.16 is released](https://github.com/chocolatey/choco/milestone/43), the following workarounds are available: +- Specify `RequiredVersion` if possible + ```PowerShell + Install-Package ninja -RequiredVersion 1.9.0 -Provider ChocolateyGet + ``` +- Downgrade Chocolatey to 0.10.13 until 0.10.16 is released (ChocolateyGet installs 0.10.13 by default) + ```PowerShell + Install-Package chocolatey -RequiredVersion 0.10.13 -Provider ChocolateyGet -Force + Install-Package ninja -MaximumVersion 1.9.0 -Provider ChocolateyGet + ``` +- If you **must** use Chocolatey 0.10.14 or 0.10.15 for some reason, include the environment variable CHOCO_NONEXACT_SEARCH + ```PowerShell + $env:CHOCO_NONEXACT_SEARCH = $true + Install-Package ninja -MaximumVersion 1.9.0 -Provider ChocolateyGet + ``` + - Please note - this will revert the default search behavior change requested in (#20) +- Use ChocolateyGet via PowerShell v5 or below in Native API mode, which uses Chocolatey version 0.10.13 + + ## Legal and Licensing ChocolateyGet is licensed under the [MIT license](./LICENSE.txt). diff --git a/appveyor.yml b/appveyor.yml index 744549d..5a54481 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -17,7 +17,7 @@ build_script: test_script: - ps: Invoke-Pester -EnableExit -OutputFormat NUnitXml -OutputFile TestsResults.NativeAPI.xml - ps: (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\TestsResults.NativeAPI.xml)) - - pwsh: choco install chocolatey -y --version 0.10.13 --allow-downgrade + - pwsh: Install-Package chocolatey -RequiredVersion 0.10.13 -ProviderName ChocolateyGet -Force - pwsh: Invoke-Pester -EnableExit -OutputFormat NUnitXml -OutputFile TestsResults.CLI.xml - pwsh: (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\TestsResults.CLI.xml)) diff --git a/src/private/Invoke-Choco.ps1 b/src/private/Invoke-Choco.ps1 index e9ce6c3..6fb6317 100644 --- a/src/private/Invoke-Choco.ps1 +++ b/src/private/Invoke-Choco.ps1 @@ -115,7 +115,7 @@ function Invoke-Choco { Invoke-Command $genericParams if ($Package) { $config.Input = $Package - if ($Version -or $AllVersions) { + if (($Version -or $AllVersions) -and -not $env:CHOCO_NONEXACT_SEARCH) { # Limit NuGet API result set to just the specific package name if version is specified # Have to keep choco pinned to 0.10.13 due to https://github.com/chocolatey/choco/issues/1843 - should be fixed in 0.10.16, which is still in beta $config.ListCommand.Exact = $true @@ -264,7 +264,7 @@ function Invoke-Choco { if ($Package) { $cmdString += "$Package " - if ($Version -or $AllVersions) { + if (($Version -or $AllVersions) -and -not $env:CHOCO_NONEXACT_SEARCH) { # Limit NuGet API result set to just the specific package name if version is specified # Have to keep choco pinned to 0.10.13 due to https://github.com/chocolatey/choco/issues/1843 - should be fixed in 0.10.16, which is still in beta $cmdString += "--exact " From f3da8ee3649d7a796bd97bb0c0131522d30d77d3 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 13:11:58 -0600 Subject: [PATCH 24/37] Fix CLI issue link in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ccd5b4..c7ea32b 100644 --- a/README.md +++ b/README.md @@ -209,7 +209,7 @@ Until [Chocolatey 0.10.16 is released](https://github.com/chocolatey/choco/miles $env:CHOCO_NONEXACT_SEARCH = $true Install-Package ninja -MaximumVersion 1.9.0 -Provider ChocolateyGet ``` - - Please note - this will revert the default search behavior change requested in (#20) + - Please note - this will revert the default search behavior change requested in [Issue #20](https://github.com/jianyunt/ChocolateyGet/issues/20) - Use ChocolateyGet via PowerShell v5 or below in Native API mode, which uses Chocolatey version 0.10.13 From 3ebb372851cdf64168aeccb686a9f9333ca68ece Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 13:33:54 -0600 Subject: [PATCH 25/37] Trying to track down CLI warnings in appveyor --- src/private/Invoke-Choco.ps1 | 7 ++++++- src/public/Install-Package.ps1 | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/private/Invoke-Choco.ps1 b/src/private/Invoke-Choco.ps1 index 6fb6317..44a1d7d 100644 --- a/src/private/Invoke-Choco.ps1 +++ b/src/private/Invoke-Choco.ps1 @@ -302,8 +302,13 @@ function Invoke-Choco { $output = & $ChocoExePath $cmdString if ($LASTEXITCODE -ne 0) { + # ThrowError -ExceptionName 'System.OperationCanceledException' ` + # -ExceptionMessage $($output | Out-String) ` + # -ErrorID 'JobFailure' ` + # -ErrorCategory InvalidOperation ` + # -ExceptionObject $job ThrowError -ExceptionName 'System.OperationCanceledException' ` - -ExceptionMessage $($output | Out-String) ` + -ExceptionMessage "Some output" ` -ErrorID 'JobFailure' ` -ErrorCategory InvalidOperation ` -ExceptionObject $job diff --git a/src/public/Install-Package.ps1 b/src/public/Install-Package.ps1 index 67aaf46..d0d089f 100644 --- a/src/public/Install-Package.ps1 +++ b/src/public/Install-Package.ps1 @@ -14,9 +14,13 @@ function Install-Package { # If the fast package preference doesnt match the pattern we expect, throw an exception if ((-not ($FastPackageReference -match $script:FastReferenceRegex)) -or (-not ($Matches.name -and $Matches.version))) { ThrowError -ExceptionName "System.ArgumentException" ` - -ExceptionMessage ($LocalizedData.FailToInstall -f $FastPackageReference) ` + -ExceptionMessage ($FastPackageReference) ` -ErrorId 'FailToInstall' ` -ErrorCategory InvalidArgument + # ThrowError -ExceptionName "System.ArgumentException" ` + # -ExceptionMessage ($LocalizedData.FailToInstall -f $FastPackageReference) ` + # -ErrorId 'FailToInstall' ` + # -ErrorCategory InvalidArgument } $shouldContinueQueryMessage = ($LocalizedData.InstallPackageQuery -f "Installing", $Matches.name) @@ -28,7 +32,7 @@ function Install-Package { return } - $swid = Invoke-Choco -Install -Package $Matches.name -Version $Matches.version -SourceName $Matches.source | + $swid = Invoke-Choco -Install -Package $Matches.name -Version $Matches.version -SourceName $Matches.source | Where-Object {Test-PackageVersion -Package $_ -RequiredVersion $Matches.version} if (-not $swid) { From 85f26f90ca0bb47f8d7aa62301ab35e61afac2a6 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 13:34:14 -0600 Subject: [PATCH 26/37] Track down warnings part 2 --- appveyor.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 5a54481..0c0e685 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,8 +15,6 @@ build_script: Copy-Item .\packages\log4net\lib\net40-full\log4net.dll ~\Documents\WindowsPowerShell\Modules\ChocolateyGet\lib\ -Force test_script: - - ps: Invoke-Pester -EnableExit -OutputFormat NUnitXml -OutputFile TestsResults.NativeAPI.xml - - ps: (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\TestsResults.NativeAPI.xml)) - pwsh: Install-Package chocolatey -RequiredVersion 0.10.13 -ProviderName ChocolateyGet -Force - pwsh: Invoke-Pester -EnableExit -OutputFormat NUnitXml -OutputFile TestsResults.CLI.xml - pwsh: (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\TestsResults.CLI.xml)) From da4897875f82e226887470879518acd13c7daa24 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 14:05:56 -0600 Subject: [PATCH 27/37] More appveyor CLI erorr testing --- src/private/Invoke-Choco.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/private/Invoke-Choco.ps1 b/src/private/Invoke-Choco.ps1 index 44a1d7d..ccecb62 100644 --- a/src/private/Invoke-Choco.ps1 +++ b/src/private/Invoke-Choco.ps1 @@ -307,6 +307,7 @@ function Invoke-Choco { # -ErrorID 'JobFailure' ` # -ErrorCategory InvalidOperation ` # -ExceptionObject $job + Throw 'this is my throw record:'+$LASTEXITCODE ThrowError -ExceptionName 'System.OperationCanceledException' ` -ExceptionMessage "Some output" ` -ErrorID 'JobFailure' ` From 8abf77ec697361885d56ac1f89e55b008d7ae931 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 14:17:30 -0600 Subject: [PATCH 28/37] More troubleshooting --- src/private/Invoke-Choco.ps1 | 3 +-- src/private/MiscHelpers.ps1 | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/private/Invoke-Choco.ps1 b/src/private/Invoke-Choco.ps1 index ccecb62..df78d0a 100644 --- a/src/private/Invoke-Choco.ps1 +++ b/src/private/Invoke-Choco.ps1 @@ -307,9 +307,8 @@ function Invoke-Choco { # -ErrorID 'JobFailure' ` # -ErrorCategory InvalidOperation ` # -ExceptionObject $job - Throw 'this is my throw record:'+$LASTEXITCODE ThrowError -ExceptionName 'System.OperationCanceledException' ` - -ExceptionMessage "Some output" ` + -ExceptionMessage "Some output"+$LASTEXITCODE ` -ErrorID 'JobFailure' ` -ErrorCategory InvalidOperation ` -ExceptionObject $job diff --git a/src/private/MiscHelpers.ps1 b/src/private/MiscHelpers.ps1 index 72452df..a101d0a 100644 --- a/src/private/MiscHelpers.ps1 +++ b/src/private/MiscHelpers.ps1 @@ -55,7 +55,7 @@ function ThrowError { # We need to grab and use the 'parent' (parent = 1) scope to properly return output to the user [parameter()] [System.Management.Automation.PSCmdlet] - $CallerPSCmdlet = ((Get-Variable -Scope 1 'PSCmdlet').Value), + $CallerPSCmdlet = ((Get-Variable -Scope Global 'PSCmdlet').Value), [parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] From 23ef285a73ff525eca64eca4463749ded4703883 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 14:21:58 -0600 Subject: [PATCH 29/37] More tests --- src/private/Invoke-Choco.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/private/Invoke-Choco.ps1 b/src/private/Invoke-Choco.ps1 index df78d0a..53a01df 100644 --- a/src/private/Invoke-Choco.ps1 +++ b/src/private/Invoke-Choco.ps1 @@ -308,7 +308,7 @@ function Invoke-Choco { # -ErrorCategory InvalidOperation ` # -ExceptionObject $job ThrowError -ExceptionName 'System.OperationCanceledException' ` - -ExceptionMessage "Some output"+$LASTEXITCODE ` + -ExceptionMessage "Some output $LASTEXITCODE" ` -ErrorID 'JobFailure' ` -ErrorCategory InvalidOperation ` -ExceptionObject $job From 0e11e5fef9b45f6288a39e09c7f605b20b3e9d09 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 14:26:15 -0600 Subject: [PATCH 30/37] Setting back to parent scope --- src/private/MiscHelpers.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/private/MiscHelpers.ps1 b/src/private/MiscHelpers.ps1 index a101d0a..72452df 100644 --- a/src/private/MiscHelpers.ps1 +++ b/src/private/MiscHelpers.ps1 @@ -55,7 +55,7 @@ function ThrowError { # We need to grab and use the 'parent' (parent = 1) scope to properly return output to the user [parameter()] [System.Management.Automation.PSCmdlet] - $CallerPSCmdlet = ((Get-Variable -Scope Global 'PSCmdlet').Value), + $CallerPSCmdlet = ((Get-Variable -Scope 1 'PSCmdlet').Value), [parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] From 3f8073ebd4724f1d79d912baaadaf84f66b6855a Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 14:39:44 -0600 Subject: [PATCH 31/37] Trying another scope --- src/private/Invoke-Choco.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/private/Invoke-Choco.ps1 b/src/private/Invoke-Choco.ps1 index 53a01df..f5b2573 100644 --- a/src/private/Invoke-Choco.ps1 +++ b/src/private/Invoke-Choco.ps1 @@ -308,10 +308,10 @@ function Invoke-Choco { # -ErrorCategory InvalidOperation ` # -ExceptionObject $job ThrowError -ExceptionName 'System.OperationCanceledException' ` - -ExceptionMessage "Some output $LASTEXITCODE" ` + -ExceptionMessage "The following command $ChocoExePath $cmdString failed with error code $LASTEXITCODE" ` -ErrorID 'JobFailure' ` -ErrorCategory InvalidOperation ` - -ExceptionObject $job + -CallerPSCmdlet $PSCmdlet } else { if ($Install -or ($Search -and $SourceName)) { $output | ConvertTo-SoftwareIdentity -RequestedName $Package -Source $SourceName From 6a6ff5b2f6f7fa619290faf10db995e330a25937 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 14:50:17 -0600 Subject: [PATCH 32/37] Upload choco logs --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 0c0e685..1ce4516 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -19,3 +19,5 @@ test_script: - pwsh: Invoke-Pester -EnableExit -OutputFormat NUnitXml -OutputFile TestsResults.CLI.xml - pwsh: (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\TestsResults.CLI.xml)) +after_build: + - ps: Get-ChildItem $env:programdata\chocolatey\logs | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } From 71f0169a161fbd48c70d62b1f2fad9d5f2d9d99c Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 15:01:52 -0600 Subject: [PATCH 33/37] Finally figured it out --- src/private/Invoke-Choco.ps1 | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/private/Invoke-Choco.ps1 b/src/private/Invoke-Choco.ps1 index f5b2573..d8db2dc 100644 --- a/src/private/Invoke-Choco.ps1 +++ b/src/private/Invoke-Choco.ps1 @@ -301,17 +301,12 @@ function Invoke-Choco { # Save the output to a variable so we can inspect the exit code before submitting the output to the pipeline $output = & $ChocoExePath $cmdString - if ($LASTEXITCODE -ne 0) { - # ThrowError -ExceptionName 'System.OperationCanceledException' ` - # -ExceptionMessage $($output | Out-String) ` - # -ErrorID 'JobFailure' ` - # -ErrorCategory InvalidOperation ` - # -ExceptionObject $job + # Add support for Error Code 2 (no results) for baseic enhanced error code support + if ($LASTEXITCODE -ne 0,2) { ThrowError -ExceptionName 'System.OperationCanceledException' ` -ExceptionMessage "The following command $ChocoExePath $cmdString failed with error code $LASTEXITCODE" ` -ErrorID 'JobFailure' ` -ErrorCategory InvalidOperation ` - -CallerPSCmdlet $PSCmdlet } else { if ($Install -or ($Search -and $SourceName)) { $output | ConvertTo-SoftwareIdentity -RequestedName $Package -Source $SourceName From f2a28ea4e37a85ae1a8a4f35e2e6be7d99b5115f Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 15:04:48 -0600 Subject: [PATCH 34/37] Misread the powershell docs --- src/private/Invoke-Choco.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/private/Invoke-Choco.ps1 b/src/private/Invoke-Choco.ps1 index d8db2dc..fed5867 100644 --- a/src/private/Invoke-Choco.ps1 +++ b/src/private/Invoke-Choco.ps1 @@ -302,7 +302,7 @@ function Invoke-Choco { $output = & $ChocoExePath $cmdString # Add support for Error Code 2 (no results) for baseic enhanced error code support - if ($LASTEXITCODE -ne 0,2) { + if ($LASTEXITCODE -ne 0 -and $LASTEXITCODE -ne 2) { ThrowError -ExceptionName 'System.OperationCanceledException' ` -ExceptionMessage "The following command $ChocoExePath $cmdString failed with error code $LASTEXITCODE" ` -ErrorID 'JobFailure' ` From 7d0aa23dbb7dbab2324d983ebbda7a7283f3afd6 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 15:06:59 -0600 Subject: [PATCH 35/37] typo --- src/private/Invoke-Choco.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/private/Invoke-Choco.ps1 b/src/private/Invoke-Choco.ps1 index fed5867..9a13c4a 100644 --- a/src/private/Invoke-Choco.ps1 +++ b/src/private/Invoke-Choco.ps1 @@ -301,7 +301,7 @@ function Invoke-Choco { # Save the output to a variable so we can inspect the exit code before submitting the output to the pipeline $output = & $ChocoExePath $cmdString - # Add support for Error Code 2 (no results) for baseic enhanced error code support + # Add support for Error Code 2 (no results) for basic enhanced error code support if ($LASTEXITCODE -ne 0 -and $LASTEXITCODE -ne 2) { ThrowError -ExceptionName 'System.OperationCanceledException' ` -ExceptionMessage "The following command $ChocoExePath $cmdString failed with error code $LASTEXITCODE" ` From 4759418934d33cd43b3dbea6e8a76df5f00a5131 Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 15:10:04 -0600 Subject: [PATCH 36/37] Cleanup from troubleshooting --- appveyor.yml | 2 ++ src/public/Install-Package.ps1 | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 1ce4516..60e97c7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,6 +15,8 @@ build_script: Copy-Item .\packages\log4net\lib\net40-full\log4net.dll ~\Documents\WindowsPowerShell\Modules\ChocolateyGet\lib\ -Force test_script: + - ps: Invoke-Pester -EnableExit -OutputFormat NUnitXml -OutputFile TestsResults.NativeAPI.xml + - ps: (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\TestsResults.NativeAPI.xml)) - pwsh: Install-Package chocolatey -RequiredVersion 0.10.13 -ProviderName ChocolateyGet -Force - pwsh: Invoke-Pester -EnableExit -OutputFormat NUnitXml -OutputFile TestsResults.CLI.xml - pwsh: (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\TestsResults.CLI.xml)) diff --git a/src/public/Install-Package.ps1 b/src/public/Install-Package.ps1 index d0d089f..dba20c1 100644 --- a/src/public/Install-Package.ps1 +++ b/src/public/Install-Package.ps1 @@ -14,13 +14,9 @@ function Install-Package { # If the fast package preference doesnt match the pattern we expect, throw an exception if ((-not ($FastPackageReference -match $script:FastReferenceRegex)) -or (-not ($Matches.name -and $Matches.version))) { ThrowError -ExceptionName "System.ArgumentException" ` - -ExceptionMessage ($FastPackageReference) ` + -ExceptionMessage ($LocalizedData.FailToInstall -f $FastPackageReference) ` -ErrorId 'FailToInstall' ` -ErrorCategory InvalidArgument - # ThrowError -ExceptionName "System.ArgumentException" ` - # -ExceptionMessage ($LocalizedData.FailToInstall -f $FastPackageReference) ` - # -ErrorId 'FailToInstall' ` - # -ErrorCategory InvalidArgument } $shouldContinueQueryMessage = ($LocalizedData.InstallPackageQuery -f "Installing", $Matches.name) From 87796921dc67848060727b8fd75623ab7dc947bc Mon Sep 17 00:00:00 2001 From: ethanbergstrom Date: Sat, 23 Jan 2021 15:51:56 -0600 Subject: [PATCH 37/37] Proper version comparison --- CHANGELOG.md | 4 ++++ README.md | 2 +- src/private/PackageVersionHelpers.ps1 | 10 +++++----- src/public/Install-Package.ps1 | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 688f559..abcdee0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Change default search to use exact package name if both package name and required version are specified (#20) * Requires downgrade to Chocolatey 0.10.13 due to [a Chocolatey defect](https://github.com/chocolatey/choco/issues/1843) until 0.10.16 is released +#### Fixed +* AppVeyor builds no longer fail due to change in build image permissions +* Version min/max comparison should now work properly + ## [2.0.0] - 2020-10-05 #### Added * Searching/installing/managing multiple Chocolatey sources (#5) diff --git a/README.md b/README.md index c7ea32b..5c5b464 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,7 @@ When used with CoreCLR, PowerShell 7.0.1 is a minimum requirement due to [a comp ### Save a package Save-Package is not supported with the ChocolateyGet provider, due to Chocolatey not supporting package downloads without special licensing. -### CLI Package search with MinimumVersion / MaximumVersion / AllVersions doesn't work +### CLI Package search with MaximumVersion / AllVersions return unexpected results Due to [a bug with Chocolatey](https://github.com/chocolatey/choco/issues/1843) versions 0.10.14 through 0.10.15, ChocolateyGet is unable to search packages by package range via command line as of version 2.1.0. Until [Chocolatey 0.10.16 is released](https://github.com/chocolatey/choco/milestone/43), the following workarounds are available: diff --git a/src/private/PackageVersionHelpers.ps1 b/src/private/PackageVersionHelpers.ps1 index 9971549..8a9c3ca 100644 --- a/src/private/PackageVersionHelpers.ps1 +++ b/src/private/PackageVersionHelpers.ps1 @@ -20,32 +20,32 @@ function Test-PackageVersion { $MaximumVersion ) - $version = $Package.Version.TrimStart('v') + [System.Version]$version = $Package.Version.TrimStart('v') if (-not ($RequiredVersion -or $MinimumVersion -or $MaximumVersion)) { return $true } if ($RequiredVersion) { - return ($Version -eq $RequiredVersion) + return ($Version -eq [System.Version]$RequiredVersion) } $isMatch = $false if($MinimumVersion) { - $isMatch = $version -ge $MinimumVersion + $isMatch = $version -ge [System.Version]$MinimumVersion } if($MaximumVersion) { if($MinimumVersion) { - $isMatch = $isMatch -and ($version -le $MaximumVersion) + $isMatch = $isMatch -and ($version -le [System.Version]$MaximumVersion) } else { - $isMatch = $version -le $MaximumVersion + $isMatch = $version -le [System.Version]$MaximumVersion } } diff --git a/src/public/Install-Package.ps1 b/src/public/Install-Package.ps1 index dba20c1..19f8f44 100644 --- a/src/public/Install-Package.ps1 +++ b/src/public/Install-Package.ps1 @@ -29,7 +29,7 @@ function Install-Package { } $swid = Invoke-Choco -Install -Package $Matches.name -Version $Matches.version -SourceName $Matches.source | - Where-Object {Test-PackageVersion -Package $_ -RequiredVersion $Matches.version} + Where-Object {Test-PackageVersion -Package $_ -RequiredVersion $Matches.version -ErrorAction SilentlyContinue} if (-not $swid) { # Invoke-Choco didn't throw an exception but we also couldn't pull a Software Identity from the output.