-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-DotNetRuntimeTree.ps1
69 lines (58 loc) · 1.58 KB
/
Get-DotNetRuntimeTree.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
57
58
59
60
61
62
63
64
65
66
67
68
69
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]
$RID,
[Parameter()]
[switch]
$Reverse
)
Import-Module powershell-yaml
$response = Invoke-RestMethod -Uri 'https://raw.githubusercontent.com/dotnet/runtime/main/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json'
$runtimes = $response.runtimes
function GetRuntimeTree {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string]
$RID,
[Parameter()]
[switch]
$Reverse
)
begin {
}
process {
$runtime = $runtimes.$RID
if ($Reverse) {
foreach ($currentRuntimePair in $runtimes.PSObject.Properties) {
$currentRuntime = $currentRuntimePair.Name
foreach ($import in $currentRuntimePair.Value.'#import') {
if ($RID -eq $import) {
[PSCustomObject]@{
RID = $currentRuntime
Imports = $currentRuntimePair.Value.'#import'
}
}
}
}
}
else {
$imports = @()
foreach ($import in $runtime.'#import') {
$imports += GetRuntimeTree -RID $import
}
# @{$RID = $subrids }
[PSCustomObject]@{
RID = $RID
Imports = $imports
}
}
}
end {
}
}
$tree = @()
$tree += GetRuntimeTree -RID $RID -Reverse:$Reverse
# $tree | Format-Custom -Depth 1000
$tree | ConvertTo-Yaml