(GH-95) Allow for upgrading of packages#134
(GH-95) Allow for upgrading of packages#134alphakilo45 wants to merge 7 commits intochocolatey:developmentfrom
Conversation
pauby
left a comment
There was a problem hiding this comment.
I'm not sure why there is a UpgradeLowerVersions parameter as I would imagine upgrading, rather than uninstalling / installing is not the desired behaviour?
|
I went with a |
|
@alphakilo45 I'm not clear again as to why we are using the parameter Thoughts? |
|
@pauby Only reason I can think of is when the build/pre-release tag is the only difference in the version number and that'll still be supported. I'll get the code updated. |
|
Those tests failed quite spectacularly! Can you rebase and re-push? |
1865f7e to
91e9890
Compare
…installing/reinstalling
…ity to be to upgrade a package
91e9890 to
dd0c3ff
Compare
|
Agreed - rebase didn't help so I need to find some time on keyboard to figure out what is causing that. |
|
@pauby Looks like Pester released v5 recently and that is causing issues with the tests. I fixed the maxed version in AppVeyor at 4.10.1 (the last pre-5.0.0 version) and tests are now running green. |
| function Get-VersionCore { | ||
| [CmdletBinding()] | ||
| param ( | ||
| [string]$Version | ||
| ) | ||
|
|
||
| [Version] $versionCore = $null | ||
| if ($Version -match '(?<Major>[1-9]\d*)(\.(?<Minor>[0-9]*))?(\.(?<Patch>[0-9]*))?(\.(?<Segment>[0-9]*))?([-+].*)?') { | ||
| $versionCore = New-Object System.Version($Matches.Major, $Matches.Minor, $Matches.Patch, $Matches.Segment) | ||
| } | ||
|
|
||
| $versionCore | ||
| } |
There was a problem hiding this comment.
This doesn't compare prerelease versions so 3.0.0-beta1 and 3.0.0-beta2 are the same. So in this instance the code calling it would actually uninstall 3.0.0-beta1 and install 3.0.0-beta2 rather than upgrade.
| [Parameter(Position=4)] | ||
| [string]$pVersion |
There was a problem hiding this comment.
If you look at line 146 above you've got:
$chocoParams += " --version='$versionToInstall'"
Upgrade-Package -pName $Name -pParams $Params -pSource $Source -cParams $chocoParams
The version parameter is added in the calling code by adding it to -cParams parameter. So I'm unsure why we need a specific parameter here that does nothing more than add it into the Choco parameters?
| if ($pVersion) { | ||
| $chocoParams += " --version=`"$pVersion`"" | ||
| } |
There was a problem hiding this comment.
This is the code I was talking about above.
This is related to #95 and adds a new resource parameter called
UpgradeLowerVersionsthat causes the cChocoPackageInstall resource to callchoco updateinstead of executing an uninstall/install when the package is already installed and on a lower version.