@@ -68,19 +68,19 @@ private record class ReferenceInfo(string? Type, Dictionary<string, object>? Com
68
68
/// }
69
69
/// }
70
70
///
71
- /// Returns dependencies
72
- /// RequiredPaths = {
71
+ /// Adds the following dependencies
72
+ /// Paths: {
73
73
/// "castle.core/4.4.1/lib/netstandard1.5/Castle.Core.dll",
74
74
/// "json.net/1.0.33/lib/netstandard2.0/Json.Net.dll"
75
75
/// }
76
- /// UsedPackages = {
76
+ /// Packages: {
77
77
/// "castle.core",
78
78
/// "json.net"
79
79
/// }
80
80
/// </summary>
81
- private DependencyContainer AddPackageDependencies ( JObject json , DependencyContainer dependencies )
81
+ private void AddPackageDependencies ( JObject json , DependencyContainer dependencies )
82
82
{
83
- // If there are more than one framework we need to pick just one.
83
+ // If there is more than one framework we need to pick just one.
84
84
// To ensure stability we pick one based on the lexicographic order of
85
85
// the framework names.
86
86
var references = json
@@ -93,7 +93,7 @@ private DependencyContainer AddPackageDependencies(JObject json, DependencyConta
93
93
if ( references is null )
94
94
{
95
95
progressMonitor . LogDebug ( "No references found in the targets section in the assets file." ) ;
96
- return dependencies ;
96
+ return ;
97
97
}
98
98
99
99
// Find all the compile dependencies for each reference and
@@ -111,7 +111,7 @@ private DependencyContainer AddPackageDependencies(JObject json, DependencyConta
111
111
// If this is a .NET framework reference then include everything.
112
112
if ( netFrameworks . Any ( framework => name . StartsWith ( framework ) ) )
113
113
{
114
- dependencies . Add ( name ) ;
114
+ dependencies . AddFramework ( name ) ;
115
115
}
116
116
else
117
117
{
@@ -120,7 +120,69 @@ private DependencyContainer AddPackageDependencies(JObject json, DependencyConta
120
120
}
121
121
} ) ;
122
122
123
- return dependencies ;
123
+ return ;
124
+ }
125
+
126
+ /// <summary>
127
+ /// Add the framework dependencies from the assets file to dependencies.
128
+ ///
129
+ /// Example:
130
+ /// "project": {
131
+ // "version": "1.0.0",
132
+ // "frameworks": {
133
+ // "net7.0": {
134
+ // "frameworkReferences": {
135
+ // "Microsoft.AspNetCore.App": {
136
+ // "privateAssets": "none"
137
+ // },
138
+ // "Microsoft.NETCore.App": {
139
+ // "privateAssets": "all"
140
+ // }
141
+ // }
142
+ // }
143
+ // }
144
+ // }
145
+ //
146
+ /// Adds the following dependencies
147
+ /// Paths: {
148
+ /// "microsoft.aspnetcore.app.ref",
149
+ /// "microsoft.netcore.app.ref"
150
+ /// }
151
+ /// Packages: {
152
+ /// "microsoft.aspnetcore.app.ref",
153
+ /// "microsoft.netcore.app.ref"
154
+ /// }
155
+ /// </summary>
156
+ private void AddFrameworkDependencies ( JObject json , DependencyContainer dependencies )
157
+ {
158
+
159
+ var frameworks = json
160
+ . GetProperty ( "project" ) ?
161
+ . GetProperty ( "frameworks" ) ;
162
+
163
+ if ( frameworks is null )
164
+ {
165
+ progressMonitor . LogDebug ( "No framework section in assets.json." ) ;
166
+ return ;
167
+ }
168
+
169
+ // If there is more than one framework we need to pick just one.
170
+ // To ensure stability we pick one based on the lexicographic order of
171
+ // the framework names.
172
+ var references = frameworks
173
+ . Properties ( ) ?
174
+ . MaxBy ( p => p . Name ) ?
175
+ . Value [ "frameworkReferences" ] as JObject ;
176
+
177
+ if ( references is null )
178
+ {
179
+ progressMonitor . LogDebug ( "No framework references in assets.json." ) ;
180
+ return ;
181
+ }
182
+
183
+ references
184
+ . Properties ( )
185
+ . ForEach ( f => dependencies . AddFramework ( $ "{ f . Name } .Ref". ToLowerInvariant ( ) ) ) ;
124
186
}
125
187
126
188
/// <summary>
@@ -134,6 +196,7 @@ public bool TryParse(string json, DependencyContainer dependencies)
134
196
{
135
197
var obj = JObject . Parse ( json ) ;
136
198
AddPackageDependencies ( obj , dependencies ) ;
199
+ AddFrameworkDependencies ( obj , dependencies ) ;
137
200
return true ;
138
201
}
139
202
catch ( Exception e )
0 commit comments