From c8f5a1997796dfb780c86f86eaee3de071509ca7 Mon Sep 17 00:00:00 2001 From: jrdnr Date: Sun, 3 Dec 2017 16:09:03 -0500 Subject: [PATCH 01/15] Choco Versions >10.4 overwhelm log with download Progress data Added Check for Choco version and add "--no-progress" to the Params list - Renamed Params variable for consistency across functions - Updated Choco comand execution formatting to be consistent across functions --- .../cChocoPackageInstall.psm1 | 70 ++++++++++++------- 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 index 4e1afb4..5709cb5 100644 --- a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 +++ b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 @@ -226,23 +226,29 @@ function InstallPackage $env:Path = [Environment]::GetEnvironmentVariable('Path','Machine') - [string]$chocoinstallparams = '-y' + [string]$chocoParams = '-y' if ($pParams) { - $chocoinstallparams += " --params=`"$pParams`"" + $chocoParams += " --params=`"$pParams`"" } if ($pVersion) { - $chocoinstallparams += " --version=`"$pVersion`"" + $chocoParams += " --version=`"$pVersion`"" } if ($pSource) { - $chocoinstallparams += " --source=`"$pSource`"" + $chocoParams += " --source=`"$pSource`"" } if ($cParams) { - $chocoinstallparams += " $cParams" + $chocoParams += " $cParams" + } + # Check if Chocolatey version is Greater than 0.10.4, and add --no-progress + $chocoVer = [system.version](Get-ChocoInstalledPackage | Where-Object { $_.name -eq 'chocolatey' }).Version + if ($chocoVer -ge 0.10.4) { + $chocoParams += " --no-progress" } - Write-Verbose -Message "Install command: 'choco install $pName $chocoinstallparams'" - $packageInstallOuput = Invoke-Expression -Command "choco install $pName $chocoinstallparams" - Write-Verbose -Message "Package output $packageInstallOuput " + $cmd = "choco install $pName $chocoParams" + Write-Verbose -Message "Install command: '$cmd'" + $packageInstallOuput = Invoke-Expression -Command $cmd + Write-Verbose -Message "Package output $packageInstallOuput" # Clear Package Cache Get-ChocoInstalledPackage 'Purge' @@ -262,17 +268,22 @@ function UninstallPackage $env:Path = [Environment]::GetEnvironmentVariable('Path','Machine') - #Todo: Refactor - if (-not ($pParams)) - { - Write-Verbose -Message 'Uninstalling Package Standard' - $packageUninstallOuput = choco uninstall $pName -y + [string]$chocoParams = "-y" + if ($pParams) { + $chocoParams += " --params=`"$pParams`"" } - elseif ($pParams) - { - Write-Verbose -Message "Uninstalling Package with params $pParams" - $packageUninstallOuput = choco uninstall $pName --params="$pParams" -y + if ($pVersion) { + $chocoParams += " --version=`"$pVersion`"" } + # Check if Chocolatey version is Greater than 0.10.4, and add --no-progress + $chocoVer = [system.version](Get-ChocoInstalledPackage | Where-Object { $_.name -eq 'chocolatey' }).Version + if ($chocoVer -ge 0.10.4) { + $chocoParams += " --no-progress" + } + + $cmd = "choco uninstall $pName $chocoParams" + Write-Verbose -Message "Uninstalling $pName with: '$cmd'" + $packageUninstallOuput = Invoke-Expression -Command $cmd Write-Verbose -Message "Package uninstall output $packageUninstallOuput " @@ -325,14 +336,15 @@ Function Test-LatestVersionInstalled { ) Write-Verbose -Message "Testing if $pName can be upgraded" - [string]$chocoupgradeparams = '--noop' + [string]$chocoParams = '--noop' if ($pSource) { - $chocoupgradeparams += " --source=`"$pSource`"" + $chocoParams += " --source=`"$pSource`"" } - Write-Verbose -Message "Testing if $pName can be upgraded: 'choco upgrade $pName $chocoupgradeparams'" + $cmd = "choco upgrade $pName $chocoParams" + Write-Verbose -Message "Testing if $pName can be upgraded: '$cmd'" - $packageUpgradeOuput = Invoke-Expression -Command "choco upgrade $pName $chocoupgradeparams" + $packageUpgradeOuput = Invoke-Expression -Command $cmd $packageUpgradeOuput | ForEach-Object {Write-Verbose -Message $_} if ($packageUpgradeOuput -match "$pName.*is the latest version available based on your source") { @@ -379,17 +391,23 @@ Function Upgrade-Package { $env:Path = [Environment]::GetEnvironmentVariable('Path','Machine') Write-Verbose -Message "Path variables: $env:Path" - [string]$chocoupgradeparams = '-dv -y' + [string]$chocoParams = '-dv -y' if ($pParams) { - $chocoupgradeparams += " --params=`"$pParams`"" + $chocoParams += " --params=`"$pParams`"" } if ($pSource) { - $chocoupgradeparams += " --source=`"$pSource`"" + $chocoParams += " --source=`"$pSource`"" } if ($cParams) { - $chocoupgradeparams += " $cParams" + $chocoParams += " $cParams" } - $cmd = "choco upgrade $pName $chocoupgradeparams" + # Check if Chocolatey version is Greater than 0.10.4, and add --no-progress + $chocoVer = [system.version](Get-ChocoInstalledPackage | Where-Object { $_.name -eq 'chocolatey' }).Version + if ($chocoVer -ge 0.10.4) { + $chocoParams += " --no-progress" + } + + $cmd = "choco upgrade $pName $chocoParams" Write-Verbose -Message "Upgrade command: '$cmd'" if (-not (IsPackageInstalled -pName $pName)) From b345453d84f099981c209042771e20c38f998f7b Mon Sep 17 00:00:00 2001 From: jrdnr Date: Sun, 3 Dec 2017 16:24:19 -0500 Subject: [PATCH 02/15] Fix Pester Test run Failure Adds "[Diagnostics.CodeAnalysis.SuppressMessage('PSAvoidUsingInvokeExpression','')]" to function UninstallPackage, to match other functions that use InvokeExpression to call Chco --- DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 | 1 + 1 file changed, 1 insertion(+) diff --git a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 index 5709cb5..97636df 100644 --- a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 +++ b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 @@ -259,6 +259,7 @@ function InstallPackage function UninstallPackage { + [Diagnostics.CodeAnalysis.SuppressMessage('PSAvoidUsingInvokeExpression','')] param( [Parameter(Position=0,Mandatory)] [string]$pName, From 971ab35d363d0d015a174830c96ac164e32ca0da Mon Sep 17 00:00:00 2001 From: jrdnr Date: Fri, 8 Dec 2017 13:52:42 -0500 Subject: [PATCH 03/15] Powershell cannot compair 0.10.4 to a version number Powershell needs versions to be specified as strings in order to compair them to version numbers. Updated to '0.10.4' insure accurate logic. --- DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 index 97636df..9297c16 100644 --- a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 +++ b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 @@ -241,7 +241,7 @@ function InstallPackage } # Check if Chocolatey version is Greater than 0.10.4, and add --no-progress $chocoVer = [system.version](Get-ChocoInstalledPackage | Where-Object { $_.name -eq 'chocolatey' }).Version - if ($chocoVer -ge 0.10.4) { + if ($chocoVer -ge '0.10.4') { $chocoParams += " --no-progress" } @@ -278,7 +278,7 @@ function UninstallPackage } # Check if Chocolatey version is Greater than 0.10.4, and add --no-progress $chocoVer = [system.version](Get-ChocoInstalledPackage | Where-Object { $_.name -eq 'chocolatey' }).Version - if ($chocoVer -ge 0.10.4) { + if ($chocoVer -ge '0.10.4') { $chocoParams += " --no-progress" } @@ -404,7 +404,7 @@ Function Upgrade-Package { } # Check if Chocolatey version is Greater than 0.10.4, and add --no-progress $chocoVer = [system.version](Get-ChocoInstalledPackage | Where-Object { $_.name -eq 'chocolatey' }).Version - if ($chocoVer -ge 0.10.4) { + if ($chocoVer -ge '0.10.4') { $chocoParams += " --no-progress" } From 6eb98994af06dbb246396787c34f9c5ff92cda54 Mon Sep 17 00:00:00 2001 From: jrdnr Date: Mon, 11 Dec 2017 10:24:12 -0500 Subject: [PATCH 04/15] Implemented caching choco version Ensured explicitly casting '0.10.4' to Version --- .../cChocoPackageInstall.psm1 | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 index 9297c16..1fd22bf 100644 --- a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 +++ b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 @@ -240,8 +240,7 @@ function InstallPackage $chocoParams += " $cParams" } # Check if Chocolatey version is Greater than 0.10.4, and add --no-progress - $chocoVer = [system.version](Get-ChocoInstalledPackage | Where-Object { $_.name -eq 'chocolatey' }).Version - if ($chocoVer -ge '0.10.4') { + if ((Get-ChocoVersion) -ge [version]('0.10.4')){ $chocoParams += " --no-progress" } @@ -277,8 +276,7 @@ function UninstallPackage $chocoParams += " --version=`"$pVersion`"" } # Check if Chocolatey version is Greater than 0.10.4, and add --no-progress - $chocoVer = [system.version](Get-ChocoInstalledPackage | Where-Object { $_.name -eq 'chocolatey' }).Version - if ($chocoVer -ge '0.10.4') { + if ((Get-ChocoVersion) -ge [version]('0.10.4')){ $chocoParams += " --no-progress" } @@ -403,8 +401,7 @@ Function Upgrade-Package { $chocoParams += " $cParams" } # Check if Chocolatey version is Greater than 0.10.4, and add --no-progress - $chocoVer = [system.version](Get-ChocoInstalledPackage | Where-Object { $_.name -eq 'chocolatey' }).Version - if ($chocoVer -ge '0.10.4') { + if ((Get-ChocoVersion) -ge [version]('0.10.4')){ $chocoParams += " --no-progress" } @@ -445,4 +442,26 @@ function Get-ChocoInstalledPackage ($action) { Return $res } +function Get-ChocoVersion ($action) { + $chocoInstallCache = Join-Path -Path $env:ChocolateyInstall -ChildPath 'cache' + if ( -not (Test-Path $chocoInstallCache)){ + New-Item -Name 'cache' -Path $env:ChocolateyInstall -ItemType Directory | Out-Null + } + $chocoVersion = Join-Path -Path $chocoInstallCache -ChildPath 'ChocoVersion.xml' + + if ($action -eq 'Purge') { + Remove-Item $chocoVersion -Force + $res = $true + } else { + $cacheSec = (Get-Date).AddSeconds('-60') + if ( $cacheSec -lt (Get-Item $chocoVersion -ErrorAction SilentlyContinue).LastWriteTime ) { + $res = Import-Clixml $chocoVersion + } else { + $res = [version](choco -v) | Export-Clixml -Path $chocoVersion + } + } + + Return $res +} + Export-ModuleMember -Function *-TargetResource From 97584a643423f91e8d1072903e79071c74f8b25a Mon Sep 17 00:00:00 2001 From: jrdnr Date: Mon, 11 Dec 2017 13:10:44 -0500 Subject: [PATCH 05/15] Choco appends '-beta' to beta version numbers Added parsing to split on '-' and only use the first section. --- DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 index 1fd22bf..a43180b 100644 --- a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 +++ b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 @@ -455,9 +455,11 @@ function Get-ChocoVersion ($action) { } else { $cacheSec = (Get-Date).AddSeconds('-60') if ( $cacheSec -lt (Get-Item $chocoVersion -ErrorAction SilentlyContinue).LastWriteTime ) { - $res = Import-Clixml $chocoVersion + $res = Import-Clixml $chocoVersion } else { - $res = [version](choco -v) | Export-Clixml -Path $chocoVersion + $cmd = choco -v + $res = [version]($cmd.Split('-')[0]) + $res | Export-Clixml -Path $chocoVersion } } From d75d3f7040608d53f198d6eb810488b6dd883f70 Mon Sep 17 00:00:00 2001 From: jrdnr Date: Tue, 12 Dec 2017 12:12:09 -0500 Subject: [PATCH 06/15] Updated [Version] to Fully Qualified [System.Version] --- .../cChocoPackageInstall/cChocoPackageInstall.psm1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 index a43180b..0c9b22a 100644 --- a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 +++ b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 @@ -240,7 +240,7 @@ function InstallPackage $chocoParams += " $cParams" } # Check if Chocolatey version is Greater than 0.10.4, and add --no-progress - if ((Get-ChocoVersion) -ge [version]('0.10.4')){ + if ((Get-ChocoVersion) -ge [System.Version]('0.10.4')){ $chocoParams += " --no-progress" } @@ -276,7 +276,7 @@ function UninstallPackage $chocoParams += " --version=`"$pVersion`"" } # Check if Chocolatey version is Greater than 0.10.4, and add --no-progress - if ((Get-ChocoVersion) -ge [version]('0.10.4')){ + if ((Get-ChocoVersion) -ge [System.Version]('0.10.4')){ $chocoParams += " --no-progress" } @@ -401,7 +401,7 @@ Function Upgrade-Package { $chocoParams += " $cParams" } # Check if Chocolatey version is Greater than 0.10.4, and add --no-progress - if ((Get-ChocoVersion) -ge [version]('0.10.4')){ + if ((Get-ChocoVersion) -ge [System.Version]('0.10.4')){ $chocoParams += " --no-progress" } @@ -458,7 +458,7 @@ function Get-ChocoVersion ($action) { $res = Import-Clixml $chocoVersion } else { $cmd = choco -v - $res = [version]($cmd.Split('-')[0]) + $res = [System.Version]($cmd.Split('-')[0]) $res | Export-Clixml -Path $chocoVersion } } From 8324170341a4896cf5036523e1d4e45a6776e7aa Mon Sep 17 00:00:00 2001 From: Paul Broadwith Date: Tue, 13 Nov 2018 09:44:56 +0000 Subject: [PATCH 07/15] (maint) Formatting --- readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 4f26d20..804b804 100644 --- a/readme.md +++ b/readme.md @@ -38,11 +38,11 @@ Here's the general process of fixing an issue in the DSC Resource Kit: Build and Publishing ============================ -AppVeyor is used to package up the resource and publish to the Powershell Gallery (on successful build from a newly pushed tag only). +AppVeyor is used to package up the resource and publish to the PowerShell Gallery (on successful build from a newly pushed tag only). The AppVeyor scripts do the following: - Test the resources using 'xDSCResourceDesigner' - Verify best practises using 'PSScriptAnalyzer' - Update the version in the manifest file -- Publish the module to the powershell gallery -- Checkin updated manifest file to github +- Publish the module to the PowerShell gallery +- Check in updated manifest file to GitHub From 2a2603548fc45f9c104eeb77886a1cbe825ac743 Mon Sep 17 00:00:00 2001 From: Paul Broadwith Date: Tue, 13 Nov 2018 09:55:31 +0000 Subject: [PATCH 08/15] (maint) Add build instructions --- readme.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/readme.md b/readme.md index 804b804..dfb5e23 100644 --- a/readme.md +++ b/readme.md @@ -46,3 +46,11 @@ The AppVeyor scripts do the following: - Update the version in the manifest file - Publish the module to the PowerShell gallery - Check in updated manifest file to GitHub + +To build: + +1. Update `ModuleVersion` in `cChoco.psd1` - use `major.minor.patch.0`; +2. Update `version` in `appveyor.yml` - use `major.minor.patch.{build}`; +3. Merge development branch to master - `git checkout master`, `git merge development`; +4. Tag master with new version - `git tag v`; +5. Push changes with tag `git push v` \ No newline at end of file From d6d0275a7f69921dff440022d934e03a86a2ac9a Mon Sep 17 00:00:00 2001 From: jrdnr Date: Fri, 14 Dec 2018 22:15:55 -0500 Subject: [PATCH 09/15] Converted simple functions to "Advanced Functions" to match the rest of code --- .../cChocoPackageInstall.psm1 | 44 ++++++++++++------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 index 0c9b22a..79c2000 100644 --- a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 +++ b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 @@ -250,7 +250,7 @@ function InstallPackage Write-Verbose -Message "Package output $packageInstallOuput" # Clear Package Cache - Get-ChocoInstalledPackage 'Purge' + Get-ChocoInstalledPackage -Purge #refresh path varaible in powershell, as choco doesn"t, to pull in git $env:Path = [Environment]::GetEnvironmentVariable('Path','Machine') @@ -287,7 +287,7 @@ function UninstallPackage Write-Verbose -Message "Package uninstall output $packageUninstallOuput " # Clear Package Cache - Get-ChocoInstalledPackage 'Purge' + Get-ChocoInstalledPackage -Purge #refresh path varaible in powershell, as choco doesn"t, to pull in git $env:Path = [Environment]::GetEnvironmentVariable('Path','Machine') @@ -417,42 +417,54 @@ Function Upgrade-Package { $packageUpgradeOuput | ForEach-Object { Write-Verbose -Message $_ } # Clear Package Cache - Get-ChocoInstalledPackage 'Purge' + Get-ChocoInstalledPackage -Purge } -function Get-ChocoInstalledPackage ($action) { +function Get-ChocoInstalledPackage { + [CmdletBinding()] + param ( + [switch]$Purge, + [switch]$NoCache + ) + $ChocoInstallLP = Join-Path -Path $env:ChocolateyInstall -ChildPath 'cache' if ( -not (Test-Path $ChocoInstallLP)){ New-Item -Name 'cache' -Path $env:ChocolateyInstall -ItemType Directory | Out-Null } $ChocoInstallList = Join-Path -Path $ChocoInstallLP -ChildPath 'ChocoInstalled.xml' - if ($action -eq 'Purge') { - Remove-Item $ChocoInstallList -Force - $res = $true - } else { + if ( -not $Purge) { $PackageCacheSec = (Get-Date).AddSeconds('-60') if ( $PackageCacheSec -lt (Get-Item $ChocoInstallList -ErrorAction SilentlyContinue).LastWriteTime ) { $res = Import-Clixml $ChocoInstallList } else { - choco list -lo -r | ConvertFrom-Csv -Header 'Name', 'Version' -Delimiter "|" -OutVariable res | Export-Clixml -Path $ChocoInstallList + $res = choco list -lo -r | ConvertFrom-Csv -Header 'Name', 'Version' -Delimiter "|" + if ( -not $NoCache){ + $res | Export-Clixml -Path $ChocoInstallList + } } + } else { + Remove-Item $ChocoInstallList -Force + $res = $true } Return $res } -function Get-ChocoVersion ($action) { +function Get-ChocoVersion { + [CmdletBinding()] + param ( + [switch]$Purge, + [switch]$NoCache + ) + $chocoInstallCache = Join-Path -Path $env:ChocolateyInstall -ChildPath 'cache' if ( -not (Test-Path $chocoInstallCache)){ New-Item -Name 'cache' -Path $env:ChocolateyInstall -ItemType Directory | Out-Null } $chocoVersion = Join-Path -Path $chocoInstallCache -ChildPath 'ChocoVersion.xml' - if ($action -eq 'Purge') { - Remove-Item $chocoVersion -Force - $res = $true - } else { + if ( -not $Purge) { $cacheSec = (Get-Date).AddSeconds('-60') if ( $cacheSec -lt (Get-Item $chocoVersion -ErrorAction SilentlyContinue).LastWriteTime ) { $res = Import-Clixml $chocoVersion @@ -461,8 +473,10 @@ function Get-ChocoVersion ($action) { $res = [System.Version]($cmd.Split('-')[0]) $res | Export-Clixml -Path $chocoVersion } + } else { + Remove-Item $chocoVersion -Force + $res = $true } - Return $res } From 23b2ad871f0fcf420542e5b0e5b2f36d35e8e0f7 Mon Sep 17 00:00:00 2001 From: jrdnr Date: Thu, 21 Mar 2019 22:16:05 -0400 Subject: [PATCH 10/15] Revered if Purge.IsPresent checks back to origional order --- .../cChocoPackageInstall/cChocoPackageInstall.psm1 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 index 79c2000..11a425e 100644 --- a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 +++ b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 @@ -433,7 +433,10 @@ function Get-ChocoInstalledPackage { } $ChocoInstallList = Join-Path -Path $ChocoInstallLP -ChildPath 'ChocoInstalled.xml' - if ( -not $Purge) { + if ($Purge) { + Remove-Item $ChocoInstallList -Force + $res = $true + } else { $PackageCacheSec = (Get-Date).AddSeconds('-60') if ( $PackageCacheSec -lt (Get-Item $ChocoInstallList -ErrorAction SilentlyContinue).LastWriteTime ) { $res = Import-Clixml $ChocoInstallList @@ -443,9 +446,6 @@ function Get-ChocoInstalledPackage { $res | Export-Clixml -Path $ChocoInstallList } } - } else { - Remove-Item $ChocoInstallList -Force - $res = $true } Return $res @@ -465,6 +465,9 @@ function Get-ChocoVersion { $chocoVersion = Join-Path -Path $chocoInstallCache -ChildPath 'ChocoVersion.xml' if ( -not $Purge) { + Remove-Item $chocoVersion -Force + $res = $true + } else { $cacheSec = (Get-Date).AddSeconds('-60') if ( $cacheSec -lt (Get-Item $chocoVersion -ErrorAction SilentlyContinue).LastWriteTime ) { $res = Import-Clixml $chocoVersion @@ -473,9 +476,6 @@ function Get-ChocoVersion { $res = [System.Version]($cmd.Split('-')[0]) $res | Export-Clixml -Path $chocoVersion } - } else { - Remove-Item $chocoVersion -Force - $res = $true } Return $res } From 548cd0c9638a20a57c7184f801d716a6ed6ccfe9 Mon Sep 17 00:00:00 2001 From: jrdnr Date: Fri, 22 Mar 2019 08:25:35 -0400 Subject: [PATCH 11/15] Corrected reversed logic in `if (-not $Purge) Using `$Purge.IsPresent` to be more explicit. --- DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 index 11a425e..5221c08 100644 --- a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 +++ b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 @@ -433,7 +433,7 @@ function Get-ChocoInstalledPackage { } $ChocoInstallList = Join-Path -Path $ChocoInstallLP -ChildPath 'ChocoInstalled.xml' - if ($Purge) { + if ($Purge.IsPresent) { Remove-Item $ChocoInstallList -Force $res = $true } else { @@ -464,7 +464,7 @@ function Get-ChocoVersion { } $chocoVersion = Join-Path -Path $chocoInstallCache -ChildPath 'ChocoVersion.xml' - if ( -not $Purge) { + if ($Purge.IsPresent) { Remove-Item $chocoVersion -Force $res = $true } else { From bfe0b43a121d617e6b1023763b5a894bc7198150 Mon Sep 17 00:00:00 2001 From: Paul Broadwith Date: Mon, 17 Jun 2019 10:27:06 +0100 Subject: [PATCH 12/15] (GH-126) Document WinRM envelope size issue --- readme.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index dfb5e23..7f8d31a 100644 --- a/readme.md +++ b/readme.md @@ -53,4 +53,10 @@ To build: 2. Update `version` in `appveyor.yml` - use `major.minor.patch.{build}`; 3. Merge development branch to master - `git checkout master`, `git merge development`; 4. Tag master with new version - `git tag v`; -5. Push changes with tag `git push v` \ No newline at end of file +5. Push changes with tag `git push v` + +## Known Issues / Troubleshooting + +### WS-Management - Exceeds the maximum envelope size allowed + +The maximum envelope size for WinRM is not sufficient for installing large packages. To increase the envelope size use `winrm set winrm/config @{MaxEnvelopeSizekb=”153600″}` - this exampe will increase it to 150MB. \ No newline at end of file From b0689474c856a148cf3f5c0cc58304fa41b64919 Mon Sep 17 00:00:00 2001 From: Paul Broadwith Date: Mon, 17 Jun 2019 10:28:06 +0100 Subject: [PATCH 13/15] (maint) Fix headings --- readme.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/readme.md b/readme.md index 7f8d31a..83f1d50 100644 --- a/readme.md +++ b/readme.md @@ -3,8 +3,7 @@ | master | [![Build status](https://ci.appveyor.com/api/projects/status/qma3jnh23w5vjt46/branch/master?svg=true&passingText=master%20-%20OK&pendingText=master%20-%20PENDING&failingText=master%20-%20FAILED)](https://ci.appveyor.com/project/LawrenceGripper/cchoco/branch/master) | | development | [![Build status](https://ci.appveyor.com/api/projects/status/qma3jnh23w5vjt46/branch/development?svg=true&passingText=development%20-%20OK&pendingText=development%20-%20PENDING&failingText=development%20-%20FAILED)](https://ci.appveyor.com/project/LawrenceGripper/cchoco/branch/development) | -Community Chocolatey DSC Resource -============================= +# Community Chocolatey DSC Resource [![Join the chat at https://gitter.im/chocolatey/cChoco](https://badges.gitter.im/chocolatey/cChoco.svg)](https://gitter.im/chocolatey/cChoco?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) @@ -16,13 +15,11 @@ See [ExampleConfig.ps1](ExampleConfig.ps1) for example usage. See list of packages here: https://chocolatey.org/packages -Contributing -============================= +## Contributing Happy to accept new features and fixes. Outstanding issues which can be worked on tagged HelpedWanted under issues. -Submitting a PR -============================= +### Submitting a PR Here's the general process of fixing an issue in the DSC Resource Kit: 1. Fork the repository. @@ -35,8 +32,7 @@ Here's the general process of fixing an issue in the DSC Resource Kit: 9. Make sure your code does not contain merge conflicts. 10. Address comments (if any). -Build and Publishing -============================ +### Build and Publishing AppVeyor is used to package up the resource and publish to the PowerShell Gallery (on successful build from a newly pushed tag only). From 0d1759c36c90b2a01cbbf28e9a6b1f2531429014 Mon Sep 17 00:00:00 2001 From: Paul Broadwith Date: Mon, 17 Jun 2019 10:29:30 +0100 Subject: [PATCH 14/15] (maint) Fix description and issue label --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 83f1d50..b8c6883 100644 --- a/readme.md +++ b/readme.md @@ -7,7 +7,7 @@ [![Join the chat at https://gitter.im/chocolatey/cChoco](https://badges.gitter.im/chocolatey/cChoco.svg)](https://gitter.im/chocolatey/cChoco?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -This resource is aimed at getting and installing packages from the choco gallery. +This resource is aimed at getting and installing packages using Chocolatey. The resource takes the name of the package and will then install that package. @@ -17,7 +17,7 @@ See list of packages here: https://chocolatey.org/packages ## Contributing -Happy to accept new features and fixes. Outstanding issues which can be worked on tagged HelpedWanted under issues. +Happy to accept new features and fixes. Outstanding issues which can be worked on tagged `Up For Grabs` under issues. ### Submitting a PR From 5b3ceeff0561c871067bbe4bf09f47b6d822ff81 Mon Sep 17 00:00:00 2001 From: Marko Bozikovic Date: Fri, 3 Jan 2020 16:29:10 +0100 Subject: [PATCH 15/15] [#135] A fix for passing custom source name in cChocoPackageInstaller Test-TargetResource --- .../cChocoPackageInstall/cChocoPackageInstall.psm1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 index 156de19..5caaa51 100644 --- a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 +++ b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 @@ -165,10 +165,13 @@ function Test-TargetResource Write-Verbose -Message "Checking if $Name is installed" if ($AutoUpgrade -and $isInstalled) { + $testParams = @{ + pName = $Name + } if ($Source){ - [string]$pSource = "-pSource `"$Source`"" + $testParams.pSource = $Source } - $result = Test-LatestVersionInstalled -pName $Name $pSource + $result = Test-LatestVersionInstalled @testParams } else { $result = $isInstalled }