Skip to content

Instantly share code, notes, and snippets.

@bchap1n
Created July 22, 2021 01:47
Show Gist options
  • Select an option

  • Save bchap1n/28f9ec4b876f144a38ab07408c01f3f0 to your computer and use it in GitHub Desktop.

Select an option

Save bchap1n/28f9ec4b876f144a38ab07408c01f3f0 to your computer and use it in GitHub Desktop.
Add this as a 'Task' in PSDepend to force running the chocolatey.ps1 dependency script on PowerShell Core
# PSDepend 0.3.8 doesn't yet support Choco dependency type on powershell core
# This script will read the choco dependencies in your *requirements.psd1 and then run them against the chocolatey.ps1 dependency script
# alternatively you could add 'core' to your PSDependMap.psd1 file which also worked for me, but won't survive a module upgrade
param(
[string]$DependsTypeString = 'Chocolatey',
[ValidateSet('Test', 'Install')]
[string[]]$PSDependAction = 'Install',
[securestring]$Credential,
[string]$Source,
[Switch]$Force,
$Verbose = $true
)
$PackageName = ((Get-Dependency -Path $dependencyfiles).where{ $_.dependencyType -eq $DependsTypeString }).DependencyName
$DependencyScript = (Get-PSDependScript).$DependsTypeString
foreach ($n in $PackageName) {
$DependsObject = [PSCustomObject]@{
PSTypeName = 'PSDepend.Dependency'
DependencyName = $n
Name = $n
DependencyType = $DependsTypeString
Version = 'latest'
Source = $Source
Credential = $Credential
}
. $DependencyScript -Dependency $DependsObject -PSDependAction $PSDependAction -Force:$Force -Verbose:$verbose
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment