-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnailDownNuget.ps1
56 lines (47 loc) · 1.33 KB
/
nailDownNuget.ps1
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
$slnPath=$args[0]
$nugetName=$args[1]
$nugetVersion=$args[2]
function Find-Nuget
{
param (
[string]$path,
[string]$currentElementName,
[string]$currentElementVersion,
[string]$nugetName,
[string]$nugetVersion,
[object[]]$dependencies
)
$path = "$($path) > $($currentElementName)"
if($currentElementName.Equals($nugetName) -and $currentElementVersion.Equals($nugetVersion))
{
Write-Host "`n * Found: $($path)`n"
}
if ($dependencies.Count -eq 0)
{
return
}
else
{
foreach ($dependency in $dependencies)
{
Find-Nuget $path $dependency.id $dependency.version $nugetName $nugetVersion $dependency.dependencies
}
}
}
function Get-NugetPath
{
param (
[string]$slnPath,
[string]$nugetName,
[string]$nugetVersion
)
Write-Host "Executing nuget-deps-tree for path: '$($slnPath)'"
$dependencies = nuget-deps-tree $slnPath 2>$null #ignore stderr from nuget-deps-tree
$dependencyTree = $dependencies | ConvertFrom-Json
foreach ($project in $dependencyTree.projects)
{
Write-Host "Checking '$($project.name)'"
Find-Nuget "" $project.name "" $nugetName $nugetVersion $project.dependencies
}
}
Get-NugetPath $slnPath $nugetName $nugetVersion