@@ -157,23 +157,35 @@ private static bool IsGroupMatch(ReadOnlySpan<char> line, Regex regex, string gr
157
157
return false ;
158
158
}
159
159
160
+ private void AddPackageReference ( ReadOnlySpan < char > line , string groupName , Func < Regex > regex )
161
+ {
162
+ foreach ( var valueMatch in regex ( ) . EnumerateMatches ( line ) )
163
+ {
164
+ // We can't get the group from the ValueMatch, so doing it manually:
165
+ var packageName = GetGroup ( line , valueMatch , groupName ) . ToLowerInvariant ( ) ;
166
+ if ( ! string . IsNullOrEmpty ( packageName ) )
167
+ {
168
+ allPackages . Add ( packageName ) ;
169
+ }
170
+ }
171
+ }
172
+
160
173
private void DoInitialize ( )
161
174
{
162
175
foreach ( var file in files )
163
176
{
164
177
try
165
178
{
179
+ var isPackagesConfig = file . EndsWith ( "packages.config" , StringComparison . OrdinalIgnoreCase ) ;
180
+
166
181
foreach ( ReadOnlySpan < char > line in unsafeFileReader . ReadLines ( file ) )
167
182
{
168
183
// Find all the packages.
169
- foreach ( var valueMatch in PackageReference ( ) . EnumerateMatches ( line ) )
184
+ AddPackageReference ( line , "Include" , PackageReference ) ;
185
+
186
+ if ( isPackagesConfig )
170
187
{
171
- // We can't get the group from the ValueMatch, so doing it manually:
172
- var packageName = GetGroup ( line , valueMatch , "Include" ) . ToLowerInvariant ( ) ;
173
- if ( ! string . IsNullOrEmpty ( packageName ) )
174
- {
175
- allPackages . Add ( packageName ) ;
176
- }
188
+ AddPackageReference ( line , "id" , LegacyPackageReference ) ;
177
189
}
178
190
179
191
// Determine if ASP.NET is used.
@@ -223,6 +235,9 @@ private void DoInitialize()
223
235
[ GeneratedRegex ( "(?<!<!--.*)<PackageReference.*\\ sInclude=\" (.*?)\" .*/?>" , RegexOptions . IgnoreCase | RegexOptions . Compiled | RegexOptions . Singleline ) ]
224
236
private static partial Regex PackageReference ( ) ;
225
237
238
+ [ GeneratedRegex ( "(?<!<!--.*)<package.*\\ sid=\" (.*?)\" .*/?>" , RegexOptions . IgnoreCase | RegexOptions . Compiled | RegexOptions . Singleline ) ]
239
+ private static partial Regex LegacyPackageReference ( ) ;
240
+
226
241
[ GeneratedRegex ( "(?<!<!--.*)<FrameworkReference.*\\ sInclude=\" (.*?)\" .*/?>" , RegexOptions . IgnoreCase | RegexOptions . Compiled | RegexOptions . Singleline ) ]
227
242
private static partial Regex FrameworkReference ( ) ;
228
243
0 commit comments