-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTest-NuGetPackage.ps1
More file actions
36 lines (34 loc) · 981 Bytes
/
Test-NuGetPackage.ps1
File metadata and controls
36 lines (34 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
[CmdletBinding()]
param(
[ValidateScript({Test-Path $_})][Parameter(Mandatory)][Alias('NugetPackagePath')][string]$Path,
[string]$AssemblyName
)
Function Test-NuGetPackage {
[CmdletBinding()]
param(
[ValidateScript({Test-Path $_})][string]$Path,
[string]$AssemblyName
)
if(-not $AssemblyName) {
Write-Warning '$AssemblyName parameter is empty.'
}
$Path = Resolve-Path $Path
[bool]$assemblyFound = $false
Read-Archive -Path $Path | %{
# Look for the specific assembly within the Nuget package if $AssemblyName is provided.
if($_.Path -like "lib\*$AssemblyName.dll") {
$assemblyFound = $true
Write-Information -
}
}
if(-not $assemblyFound) {
Write-Error "No assembly found in 'lib' directory."
Write-Output $false
}
else {
Write-Output $true
}
}
if($PSBoundParameters.Count -gt 0) {
Test-NuGetPackage @PSBoundParameters
}