-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnailDownNuget.py
43 lines (30 loc) · 1.31 KB
/
nailDownNuget.py
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
import argparse
import subprocess
import json
parser = argparse.ArgumentParser()
parser.add_argument('slnpath')
parser.add_argument('nugetName')
parser.add_argument('nugetVersion')
args = parser.parse_args()
def find_nuget(path, currentElementName, currentElementVersion, nugetName, nugetVersion, dependencies):
resultPath = "{} > {}".format(path, currentElementName)
if currentElementName == nugetName and currentElementVersion == nugetVersion:
print('\n* Found: {}\n'.format(resultPath))
if len(dependencies) == 0:
return
else:
for dependency in dependencies:
find_nuget(resultPath, dependency['id'], dependency['version'], nugetName, nugetVersion, dependency['dependencies'])
def main(args):
print('Executing nuget-deps-tree for path: "{}"'.format(args.slnpath))
dependenciesString = subprocess.run(
['nuget-deps-tree', args.slnpath],
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL).stdout
dependencyTree = json.loads(dependenciesString)
for project in dependencyTree['projects']:
print('Checking {}'.format(project['name']))
find_nuget("", project['name'], "", args.nugetName, args.nugetVersion, project['dependencies'])
if __name__ == '__main__':
main(args)