File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -275,7 +275,11 @@ private void Parse(string file)
275275 isSdkProjectStructureUsed = isSdkProjectStructureUsed || project is not null && reader . GetAttribute ( "Sdk" ) is not null ;
276276 isLegacyProjectStructureUsed = isLegacyProjectStructureUsed || project ? . EndsWith ( "Microsoft.CSharp.targets" , StringComparison . OrdinalIgnoreCase ) == true ;
277277 break ;
278- // TODO: we could also check `<Sdk Name="Microsoft.NET.Sdk" />`
278+ case "sdk" :
279+ var sdkName = reader . GetAttribute ( "Name" ) ;
280+ isSdkProjectStructureUsed |= sdkName != null ;
281+ useAspNetCoreDlls |= string . Equals ( sdkName , "Microsoft.NET.Sdk.Web" , StringComparison . OrdinalIgnoreCase ) ;
282+ break ;
279283 }
280284 } ) ;
281285 }
Original file line number Diff line number Diff line change @@ -247,6 +247,44 @@ public void TestFileContent_SdkProjectImport()
247247 Assert . False ( isLegacy ) ;
248248 }
249249
250+ /// <summary>
251+ /// Verifies that an SDK element indicates SDK project structure.
252+ /// </summary>
253+ [ Fact ]
254+ public void TestFileContent_SdkElement ( )
255+ {
256+ // Setup
257+ var fileContent = new TestFileContent ( "<Project><Sdk Name='Microsoft.NET.Sdk' /></Project>" ) ;
258+
259+ // Execute
260+ var isSdk = fileContent . IsSdkProjectStructureUsed ;
261+ var isLegacy = fileContent . IsLegacyProjectStructureUsed ;
262+
263+ // Verify
264+ Assert . True ( isSdk ) ;
265+ Assert . False ( isLegacy ) ;
266+ }
267+
268+ /// <summary>
269+ /// Verifies that an ASP.NET SDK element indicates ASP.NET Core usage.
270+ /// </summary>
271+ [ Fact ]
272+ public void TestFileContent_AspNetCoreSdkElement ( )
273+ {
274+ // Setup
275+ var fileContent = new TestFileContent ( "<Project><Sdk Name='Microsoft.NET.Sdk.Web' /></Project>" ) ;
276+
277+ // Execute
278+ var isSdk = fileContent . IsSdkProjectStructureUsed ;
279+ var useAspNetCoreDlls = fileContent . UseAspNetCoreDlls ;
280+ var isAspNetCoreDetected = fileContent . IsAspNetCoreDetected ;
281+
282+ // Verify
283+ Assert . True ( isSdk ) ;
284+ Assert . True ( useAspNetCoreDlls ) ;
285+ Assert . True ( isAspNetCoreDetected ) ;
286+ }
287+
250288 /// <summary>
251289 /// Verifies that `FileContent` correctly handles XML syntax with namespaces and various elements.
252290 /// </summary>
You can’t perform that action at this time.
0 commit comments