diff --git a/AppVeyor/AppVeyorBuild.ps1 b/AppVeyor/AppVeyorBuild.ps1 index 5f9a8b6..6fb7f23 100644 --- a/AppVeyor/AppVeyorBuild.ps1 +++ b/AppVeyor/AppVeyorBuild.ps1 @@ -6,6 +6,10 @@ Write-Host "ModuleName : $env:ModuleName" Write-Host "Build version : $env:APPVEYOR_BUILD_VERSION" Write-Host "Author : $env:APPVEYOR_REPO_COMMIT_AUTHOR" Write-Host "Branch : $env:APPVEYOR_REPO_BRANCH" +Write-Host "Repo : $env:APPVEYOR_REPO_NAME" +Write-Host "PSModulePath :" + +$env:PSModulePath -split ';' #---------------------------------# # BuildScript # diff --git a/AppVeyor/AppVeyorDeploy.ps1 b/AppVeyor/AppVeyorDeploy.ps1 index 2b4b8c6..816deea 100644 --- a/AppVeyor/AppVeyorDeploy.ps1 +++ b/AppVeyor/AppVeyorDeploy.ps1 @@ -17,7 +17,8 @@ Write-Host "Updating module manifest to version: $env:APPVEYOR_BUILD_VERSION" #---------------------------------# # Publish to PS Gallery # #---------------------------------# -if ($env:APPVEYOR_REPO_BRANCH -notmatch 'master') + +if ( ($env:APPVEYOR_REPO_NAME -notmatch 'PowerShellOrg') -or ($env:APPVEYOR_REPO_BRANCH -notmatch 'master') ) { Write-Host "Finished testing of branch: $env:APPVEYOR_REPO_BRANCH - Exiting" exit; diff --git a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 index fa3af7d..1ecb055 100644 --- a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 +++ b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1 @@ -60,10 +60,13 @@ function Set-TargetResource [ValidateNotNullOrEmpty()] [System.String] $Version, - [parameter(Mandatory = $false)] + [parameter(Mandatory = $false)] [ValidateNotNullOrEmpty()] [System.String] - $Source + $Source, + [parameter(Mandatory = $false)] + [String] + $chocoParams ) Write-Verbose "Start Set-TargetResource" @@ -89,7 +92,7 @@ function Set-TargetResource ($Version) -and -not ($isInstalledVersion) ` ) { - InstallPackage -pName $Name -pParams $Params -pVersion $Version + InstallPackage -pName $Name -pParams $Params -pVersion $Version -cParams $chocoParams } } elseif ($isInstalled) { @@ -118,10 +121,13 @@ function Test-TargetResource [ValidateNotNullOrEmpty()] [System.String] $Version, - [parameter(Mandatory = $false)] + [parameter(Mandatory = $false)] [ValidateNotNullOrEmpty()] [System.String] - $Source + $Source, + [parameter(Mandatory = $false)] + [String] + $chocoParams ) Write-Verbose "Start Test-TargetResource" @@ -156,43 +162,34 @@ function CheckChocoInstalled return DoesCommandExist choco } -function InstallPackage -{ - param( - [Parameter(Position=0,Mandatory=1)][string]$pName, - [Parameter(Position=1,Mandatory=0)][string]$pParams, - [Parameter(Position=2,Mandatory=0)][string]$pVersion - ) - - $env:Path = [System.Environment]::GetEnvironmentVariable('Path','Machine') - - #Todo: Refactor - if ((-not ($pParams)) -and (-not $pVersion)) - { - Write-Verbose "Installing Package Standard" - $packageInstallOuput = choco install $pName -y - } - elseif ($pParams -and $pVersion) - { - Write-Verbose "Installing Package with Params $pParams and Version $pVersion" - $packageInstallOuput = choco install $pName --params="$pParams" --version=$pVersion -y - } - elseif ($pParams) - { - Write-Verbose "Installing Package with params $pParams" - $packageInstallOuput = choco install $pName --params="$pParams" -y - } - elseif ($pVersion) - { - Write-Verbose "Installing Package with version $pVersion" - $packageInstallOuput = choco install $pName --version=$pVersion -y - } - - - Write-Verbose "Package output $packageInstallOuput " - - #refresh path varaible in powershell, as choco doesn"t, to pull in git - $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") +function InstallPackage +{ + param( + [Parameter(Position=0,Mandatory=1)][string]$pName, + [Parameter(Position=1,Mandatory=0)][string]$pParams, + [Parameter(Position=2,Mandatory=0)][string]$pVersion, + [Parameter(Position=3,Mandatory=0)][string]$cParams + ) + + $env:Path = [System.Environment]::GetEnvironmentVariable('Path','Machine') + + [string]$chocoinstallparams = '-y' + if ($pParams) { + $chocoinstallparams += " --params=`"$pParams`"" + } + if ($pVersion) { + $chocoinstallparams += " --version=`"$pVersion`"" + } + if ($cParams) { + $chocoinstallparams += " $cParams" + } + Write-Verbose "Install command: 'choco install $pName $chocoinstallparams'" + + $packageInstallOuput = Invoke-Expression "choco install $pName $chocoinstallparams" + Write-Verbose "Package output $packageInstallOuput " + + #refresh path varaible in powershell, as choco doesn"t, to pull in git + $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") } function UninstallPackage diff --git a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.schema.mof b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.schema.mof index ce6709a..59eef3d 100644 --- a/DSCResources/cChocoPackageInstall/cChocoPackageInstall.schema.mof +++ b/DSCResources/cChocoPackageInstall/cChocoPackageInstall.schema.mof @@ -6,4 +6,5 @@ class cChocoPackageInstall : OMI_BaseResource [write] string Params; [write] string Version; [write] string Source; + [Write] String chocoParams; }; diff --git a/ExampleConfig.ps1 b/ExampleConfig.ps1 index c5ba7db..05fd57c 100644 --- a/ExampleConfig.ps1 +++ b/ExampleConfig.ps1 @@ -17,6 +17,14 @@ DependsOn = "[cChocoInstaller]installChoco" } + cChocoPackageInstaller installSkypeWithChocoParams + { + Name = 'skype' + chocoParams = '--allowdowngrade --allowemptychecksum --allowemptychecksumsecure' + Ensure = 'Present' + Version = '7.25.0.106' + DependsOn = '[cChocoInstaller]installChoco' + } cChocoPackageInstaller installAtomSpecificVersion { Name = "atom" @@ -40,8 +48,7 @@ { Ensure = 'Present' Name = @( - "git" - "skype" + "git", "7zip" ) DependsOn = "[cChocoInstaller]installChoco" @@ -50,8 +57,8 @@ { Ensure = 'Absent' Name = @( - "vlc" - "ruby" + "vlc", + "ruby", "adobeair" ) DependsOn = "[cChocoInstaller]installChoco" diff --git a/appveyor.yml b/appveyor.yml index 3c55aa7..3c7615a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,6 +3,8 @@ #---------------------------------# version: 2.2.0.{build} os: WMF 5 +clone_folder: c:\projects\cChoco + install: - ps: . .\AppVeyor\AppVeyorInstall.ps1