37 lines
1.1 KiB
PowerShell
37 lines
1.1 KiB
PowerShell
function Test-PackageHasDependencyV2 {
|
|
<#
|
|
.SYNOPSIS
|
|
Returns true if the supplied nuspec file has any of the given dependencies
|
|
|
|
.PARAMETER NuspecXmlObject
|
|
[xml] A nuspec object
|
|
|
|
.PARAMETER DependencyList
|
|
[string[]] List of dependencies
|
|
#>
|
|
[CmdletBinding()]
|
|
Param(
|
|
[Alias("nuspec")]
|
|
[Parameter(Mandatory = $false)] # not required: for unit testing purposes because we test in a invoke-parallel we can't. Also it's not really super required. Something else would've failed first.
|
|
[object]$NuspecXmlObject,
|
|
[string[]]$DependencyList
|
|
)
|
|
|
|
# Get dependencies of the package
|
|
$nuspecDependencies = @($NuspecXmlObject.package.metadata.dependencies.ChildNodes | Select-Object -ExpandProperty id)
|
|
|
|
# This is the more typical case
|
|
if ($nuspecDependencies.Count -eq 0) {
|
|
return $false
|
|
}
|
|
|
|
# Figure out if the package has any of the $Dependency dependencies.
|
|
foreach($dependency in @($DependencyList)) {
|
|
if($nuspecDependencies -contains $dependency) {
|
|
return $true
|
|
}
|
|
}
|
|
|
|
return $false
|
|
}
|