22// The .NET Foundation licenses this file to you under the MIT license.
33// See the LICENSE file in the project root for more information.
44
5+ using System ;
56using System . Collections . Generic ;
67using System . IO ;
78using System . Linq ;
@@ -20,7 +21,7 @@ public class WebScenarioTests : SdkTests
2021{
2122 public WebScenarioTests ( ITestOutputHelper outputHelper ) : base ( outputHelper ) { }
2223
23- // [Theory(Skip="https://github.com/dotnet/sdk/issues/42920") ]
24+ [ Theory ]
2425 [ MemberData ( nameof ( GetScenarioObjects ) ) ]
2526 public void VerifyScenario ( TestScenario scenario ) => scenario . Execute ( DotNetHelper ) ;
2627
@@ -37,8 +38,7 @@ private static IEnumerable<TestScenario> GetScenarios()
3738
3839 yield return new ( nameof ( WebScenarioTests ) , DotNetLanguage . CSharp , DotNetTemplate . Razor , DotNetActions . Build | DotNetActions . Run | DotNetActions . Publish ) ;
3940 yield return new ( nameof ( WebScenarioTests ) , DotNetLanguage . CSharp , DotNetTemplate . BlazorWasm , DotNetActions . Build | DotNetActions . Run | DotNetActions . Publish ) ;
40- // Disabled due to .NET 10.0 transition. See https://github.com/dotnet/sdk/pull/42969
41- // yield return new(nameof(WebScenarioTests), DotNetLanguage.CSharp, DotNetTemplate.WebApp, DotNetActions.PublishSelfContained, VerifyRuntimePacksForSelfContained);
41+ yield return new ( nameof ( WebScenarioTests ) , DotNetLanguage . CSharp , DotNetTemplate . WebApp , DotNetActions . PublishSelfContained , VerifyRuntimePacksForSelfContained ) ;
4242 yield return new ( nameof ( WebScenarioTests ) , DotNetLanguage . CSharp , DotNetTemplate . Worker ) ;
4343 }
4444
@@ -50,9 +50,30 @@ private static void VerifyRuntimePacksForSelfContained(string projectPath)
5050 string projNugetCachePath = Path . Combine ( projectPath , "obj" , "project.nuget.cache" ) ;
5151
5252 JsonNode ? projNugetCache = JsonNode . Parse ( File . ReadAllText ( projNugetCachePath ) ) ;
53- string ? restoredPackageFiles = projNugetCache ? [ "expectedPackageFiles" ] ? . ToString ( ) ;
53+ JsonArray ? restoredPackageFiles = ( JsonArray ? ) projNugetCache ? [ "expectedPackageFiles" ] ;
5454
5555 Assert . True ( restoredPackageFiles is not null , "Failed to parse project.nuget.cache" ) ;
56- Assert . True ( "[]" == restoredPackageFiles , "Runtime packs were retrieved from NuGet instead of the SDK" ) ;
56+
57+ string [ ] allowedPackages = [
58+ // Temporarily allowed due to https://github.com/dotnet/sdk/issues/46165
59+ // TODO: Remove this once the issue is resolved
60+ "Microsoft.AspNetCore.App.Internal.Assets"
61+ ] ;
62+
63+ string packagesDirectory = Path . Combine ( Environment . CurrentDirectory , "packages" ) ;
64+
65+ IEnumerable < string > packages = restoredPackageFiles
66+ . Select ( file =>
67+ {
68+ string path = file . ToString ( ) ;
69+ path = path . Substring ( packagesDirectory . Length + 1 ) ; // trim the leading path up to the package name directory
70+ return path . Substring ( 0 , path . IndexOf ( '/' ) ) ; // trim the rest of the path
71+ } )
72+ . Except ( allowedPackages , StringComparer . OrdinalIgnoreCase ) ;
73+
74+ if ( packages . Any ( ) )
75+ {
76+ Assert . Fail ( $ "The following runtime packs were retrieved from NuGet instead of the SDK: { string . Join ( "," , packages . ToArray ( ) ) } ") ;
77+ }
5778 }
5879}
0 commit comments