@@ -68,19 +68,19 @@ private record class ReferenceInfo(string? Type, Dictionary<string, object>? Com
6868 /// }
6969 /// }
7070 ///
71- /// Returns dependencies
72- /// RequiredPaths = {
71+ /// Adds the following dependencies
72+ /// Paths: {
7373 /// "castle.core/4.4.1/lib/netstandard1.5/Castle.Core.dll",
7474 /// "json.net/1.0.33/lib/netstandard2.0/Json.Net.dll"
7575 /// }
76- /// UsedPackages = {
76+ /// Packages: {
7777 /// "castle.core",
7878 /// "json.net"
7979 /// }
8080 /// </summary>
81- private DependencyContainer AddPackageDependencies ( JObject json , DependencyContainer dependencies )
81+ private void AddPackageDependencies ( JObject json , DependencyContainer dependencies )
8282 {
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.
8484 // To ensure stability we pick one based on the lexicographic order of
8585 // the framework names.
8686 var references = json
@@ -93,7 +93,7 @@ private DependencyContainer AddPackageDependencies(JObject json, DependencyConta
9393 if ( references is null )
9494 {
9595 progressMonitor . LogDebug ( "No references found in the targets section in the assets file." ) ;
96- return dependencies ;
96+ return ;
9797 }
9898
9999 // Find all the compile dependencies for each reference and
@@ -111,7 +111,7 @@ private DependencyContainer AddPackageDependencies(JObject json, DependencyConta
111111 // If this is a .NET framework reference then include everything.
112112 if ( netFrameworks . Any ( framework => name . StartsWith ( framework ) ) )
113113 {
114- dependencies . Add ( name ) ;
114+ dependencies . AddFramework ( name ) ;
115115 }
116116 else
117117 {
@@ -120,7 +120,69 @@ private DependencyContainer AddPackageDependencies(JObject json, DependencyConta
120120 }
121121 } ) ;
122122
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 ( ) ) ) ;
124186 }
125187
126188 /// <summary>
@@ -134,6 +196,7 @@ public bool TryParse(string json, DependencyContainer dependencies)
134196 {
135197 var obj = JObject . Parse ( json ) ;
136198 AddPackageDependencies ( obj , dependencies ) ;
199+ AddFrameworkDependencies ( obj , dependencies ) ;
137200 return true ;
138201 }
139202 catch ( Exception e )
0 commit comments