|
| 1 | +# Platform-Aware Installation Flow |
| 2 | + |
| 3 | +## Extraction Filtering Pipeline |
| 4 | + |
| 5 | +```mermaid |
| 6 | +flowchart TD |
| 7 | + A["Install-PSResource -Name MyModule<br/>[-SkipRuntimeFiltering] [-RuntimeIdentifier] [-TargetFramework]"] --> B["1. Download .nupkg from gallery<br/>(full package, all platforms)"] |
| 8 | + B --> C["2. Open as ZipArchive in TryExtractToDirectory()"] |
| 9 | + C --> D["Detect TFM"] |
| 10 | + C --> E["Detect RID"] |
| 11 | +
|
| 12 | + D --> D1{"-TargetFramework<br/>specified?"} |
| 13 | + D1 -->|YES| D2["Parse user value<br/>NuGetFramework.ParseFolder()"] |
| 14 | + D1 -->|NO| D3["Auto-detect via<br/>GetCurrentFramework()"] |
| 15 | + D2 --> D4["GetBestLibFramework()<br/>FrameworkReducer.GetNearest()<br/>→ Best TFM e.g., net8.0"] |
| 16 | + D3 --> D4 |
| 17 | +
|
| 18 | + E --> E1{"-RuntimeIdentifier<br/>specified?"} |
| 19 | + E1 -->|YES| E2["Use user value<br/>e.g., linux-x64"] |
| 20 | + E1 -->|NO| E3["DetectRuntimeIdentifier()<br/>ProcessArchitecture + OSPlatform"] |
| 21 | + E2 --> E4["Target RID<br/>e.g., win-x64"] |
| 22 | + E3 --> E4 |
| 23 | +
|
| 24 | + D4 --> F["3. Filter each zip entry"] |
| 25 | + E4 --> F |
| 26 | +
|
| 27 | + F --> G{"Entry type?"} |
| 28 | +
|
| 29 | + G -->|"runtimes/**"| H{"-SkipRuntimeFiltering?"} |
| 30 | + H -->|YES| I["✅ INCLUDE all runtimes"] |
| 31 | + H -->|NO| J{"ShouldIncludeEntry()<br/>RID compatible?"} |
| 32 | + J -->|"runtimes/win-x64/ vs win-x64"| K["✅ INCLUDE"] |
| 33 | + J -->|"runtimes/linux-arm64/ vs win-x64"| L["❌ SKIP"] |
| 34 | + J -->|"runtimes/osx-arm64/ vs win-x64"| L |
| 35 | +
|
| 36 | + G -->|"lib/**"| M{"Best TFM<br/>match found?"} |
| 37 | + M -->|NO| N["✅ INCLUDE all lib/ entries"] |
| 38 | + M -->|YES| O{"ShouldIncludeLibEntry()<br/>TFM matches best?"} |
| 39 | + O -->|"lib/net8.0/ vs best net8.0"| P["✅ INCLUDE"] |
| 40 | + O -->|"lib/net472/ vs best net8.0"| Q["❌ SKIP"] |
| 41 | + O -->|"lib/netstandard2.0/ vs best net8.0"| Q |
| 42 | +
|
| 43 | + G -->|"*.psd1, *.psm1, etc."| R["✅ INCLUDE always"] |
| 44 | +
|
| 45 | + K --> S["4. DeleteExtraneousFiles()<br/>Delete: Content_Types.xml, _rels/, package/, .nuspec"] |
| 46 | + I --> S |
| 47 | + N --> S |
| 48 | + P --> S |
| 49 | + R --> S |
| 50 | +
|
| 51 | + S --> T["5. Installed Module<br/>MyModule/1.0.0/<br/>├── MyModule.psd1<br/>├── lib/net8.0/ ← only best TFM<br/>└── runtimes/win-x64/ ← only matching RID"] |
| 52 | +
|
| 53 | + click A "src/code/InstallPSResource.cs#L147" "InstallPSResource.cs — cmdlet parameters" |
| 54 | + click C "src/code/InstallHelper.cs#L1181" "InstallHelper.TryExtractToDirectory()" |
| 55 | + click D3 "src/code/InstallHelper.cs#L1394" "InstallHelper.GetCurrentFramework()" |
| 56 | + click D4 "src/code/InstallHelper.cs#L1289" "InstallHelper.GetBestLibFramework()" |
| 57 | + click E3 "src/code/RuntimeIdentifierHelper.cs#L204" "RuntimeIdentifierHelper.DetectRuntimeIdentifier()" |
| 58 | + click J "src/code/RuntimePackageHelper.cs#L83" "RuntimePackageHelper.ShouldIncludeEntry()" |
| 59 | + click O "src/code/InstallHelper.cs#L1358" "InstallHelper.ShouldIncludeLibEntry()" |
| 60 | + click S "src/code/InstallHelper.cs#L1709" "InstallHelper.DeleteExtraneousFiles()" |
| 61 | +
|
| 62 | + style K fill:#2d6a2d,color:#fff |
| 63 | + style I fill:#2d6a2d,color:#fff |
| 64 | + style N fill:#2d6a2d,color:#fff |
| 65 | + style P fill:#2d6a2d,color:#fff |
| 66 | + style R fill:#2d6a2d,color:#fff |
| 67 | + style L fill:#8b1a1a,color:#fff |
| 68 | + style Q fill:#8b1a1a,color:#fff |
| 69 | + style T fill:#1a3d5c,color:#fff |
| 70 | +``` |
| 71 | + |
| 72 | +## Dependency Parsing (TFM-Aware) |
| 73 | + |
| 74 | +```mermaid |
| 75 | +flowchart TD |
| 76 | + A[".nuspec dependencies"] --> B{"Source type?"} |
| 77 | + |
| 78 | + B -->|"Local repo (.nuspec file)"| C["GetHashtableForNuspec()<br/>NuspecReader.GetDependencyGroups()<br/>→ ParseNuspecDependencyGroups()"] |
| 79 | + B -->|"Remote V3 (JSON)"| D["Parse dependencyGroups JSON<br/>→ TryConvertFromJson()"] |
| 80 | + |
| 81 | + C --> E["FrameworkReducer.GetNearest()<br/>picks best TFM group"] |
| 82 | + D --> E |
| 83 | + |
| 84 | + E --> F{"Current runtime?"} |
| 85 | + |
| 86 | + F -->|".NET 8 (PS 7.4)"| G["Select net8.0 group<br/>→ 0 dependencies<br/>(APIs are inbox)"] |
| 87 | + F -->|".NET Framework 4.7.2 (PS 5.1)"| H["Select net472 group<br/>→ 2 dependencies<br/>(System.Memory, System.Buffers)"] |
| 88 | +
|
| 89 | + click C "src/code/LocalServerApiCalls.cs#L958" "LocalServerApiCalls.GetHashtableForNuspec()" |
| 90 | + click D "src/code/PSResourceInfo.cs#L618" "PSResourceInfo.TryConvertFromJson()" |
| 91 | + click E "src/code/PSResourceInfo.cs#L1704" "PSResourceInfo.ParseNuspecDependencyGroups()" |
| 92 | + |
| 93 | + style G fill:#2d6a2d,color:#fff |
| 94 | + style H fill:#c47a20,color:#fff |
| 95 | +``` |
| 96 | + |
| 97 | +## Before vs After |
| 98 | + |
| 99 | +```mermaid |
| 100 | +graph LR |
| 101 | + subgraph BEFORE["Before (no filtering) — ~56 MB"] |
| 102 | + B1["lib/net472/"] |
| 103 | + B2["lib/netstandard2.0/"] |
| 104 | + B3["lib/net6.0/"] |
| 105 | + B4["lib/net8.0/ ✓"] |
| 106 | + B5["runtimes/win-x64/ ✓"] |
| 107 | + B6["runtimes/win-x86/"] |
| 108 | + B7["runtimes/linux-x64/"] |
| 109 | + B8["runtimes/linux-arm64/"] |
| 110 | + B9["runtimes/osx-x64/"] |
| 111 | + B10["runtimes/osx-arm64/"] |
| 112 | + end |
| 113 | +
|
| 114 | + subgraph AFTER["After (with filtering) — ~4 MB"] |
| 115 | + A1["lib/net8.0/ ✓"] |
| 116 | + A2["runtimes/win-x64/ ✓"] |
| 117 | + end |
| 118 | +
|
| 119 | + style B1 fill:#8b1a1a,color:#fff |
| 120 | + style B2 fill:#8b1a1a,color:#fff |
| 121 | + style B3 fill:#8b1a1a,color:#fff |
| 122 | + style B4 fill:#2d6a2d,color:#fff |
| 123 | + style B5 fill:#2d6a2d,color:#fff |
| 124 | + style B6 fill:#8b1a1a,color:#fff |
| 125 | + style B7 fill:#8b1a1a,color:#fff |
| 126 | + style B8 fill:#8b1a1a,color:#fff |
| 127 | + style B9 fill:#8b1a1a,color:#fff |
| 128 | + style B10 fill:#8b1a1a,color:#fff |
| 129 | + style A1 fill:#2d6a2d,color:#fff |
| 130 | + style A2 fill:#2d6a2d,color:#fff |
| 131 | +``` |
| 132 | + |
| 133 | +## RID Compatibility Chain |
| 134 | + |
| 135 | +```mermaid |
| 136 | +flowchart LR |
| 137 | + W1["win10-x64"] --> W2["win-x64"] --> W3["win"] --> ANY["any"] |
| 138 | + L1["linux-musl-x64"] --> L2["linux-x64"] --> L3["linux"] --> U["unix"] --> ANY |
| 139 | + O1["osx.12-arm64"] --> O2["osx-arm64"] --> O3["osx"] --> U |
| 140 | +
|
| 141 | + click W1 "src/code/RuntimeIdentifierHelper.cs#L301" "BuildCompatibleRidList()" |
| 142 | +``` |
0 commit comments