22// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33//
44
5- using System ;
6- using System . Collections . Generic ;
75using System . IO ;
86using System . Linq ;
9- using System . Text . RegularExpressions ;
107using System . Xml . Linq ;
118using Microsoft . AspNetCore . Razor . Tasks ;
129using Microsoft . NET . TestFramework . Assertions ;
@@ -18,12 +15,8 @@ namespace Microsoft.NET.Sdk.BlazorWebAssembly.Tests
1815{
1916 public class BlazorWasmStaticWebAssetsIntegrationTest : BlazorWasmBaselineTests
2017 {
21- private static readonly string DotNet5JSRegexPattern = "dotnet\\ .5\\ .[0-9]+\\ .[0-9]+\\ .js" ;
22- private readonly string DotNet5JSTemplate ;
23-
2418 public BlazorWasmStaticWebAssetsIntegrationTest ( ITestOutputHelper log ) : base ( log , GenerateBaselines )
2519 {
26- DotNet5JSTemplate = $ "dotnet.{ RuntimeVersion } .js";
2720 }
2821
2922 [ Fact ]
@@ -55,7 +48,7 @@ public void StaticWebAssets_BuildMinimal_Works()
5548 new FileInfo ( finalPath ) . Should ( ) . Exist ( ) ;
5649
5750 AssertBuildAssets (
58- StaticWebAssetsManifest . FromJsonBytes ( File . ReadAllBytes ( path ) ) ,
51+ manifest ,
5952 outputPath ,
6053 intermediateOutputPath ) ;
6154 }
@@ -85,7 +78,7 @@ public void StaticWebAssets_PublishMinimal_Works()
8578 AssertManifest ( manifest , LoadPublishManifest ( ) ) ;
8679
8780 AssertPublishAssets (
88- StaticWebAssetsManifest . FromJsonBytes ( File . ReadAllBytes ( path ) ) ,
81+ manifest ,
8982 publishPath ,
9083 intermediateOutputPath ) ;
9184 }
@@ -116,7 +109,7 @@ public void StaticWebAssets_Build_Hosted_Works()
116109 new FileInfo ( finalPath ) . Should ( ) . Exist ( ) ;
117110
118111 AssertBuildAssets (
119- StaticWebAssetsManifest . FromJsonBytes ( File . ReadAllBytes ( path ) ) ,
112+ manifest ,
120113 outputPath ,
121114 intermediateOutputPath ) ;
122115 }
@@ -147,7 +140,7 @@ public void StaticWebAssets_Publish_Hosted_Works()
147140 AssertManifest ( manifest , LoadPublishManifest ( ) ) ;
148141
149142 AssertPublishAssets (
150- StaticWebAssetsManifest . FromJsonBytes ( File . ReadAllBytes ( path ) ) ,
143+ manifest ,
151144 publishPath ,
152145 intermediateOutputPath ) ;
153146 }
@@ -178,12 +171,12 @@ public void StaticWebAssets_Publish_DoesNotIncludeXmlDocumentationFiles_AsAssets
178171 AssertManifest ( manifest , LoadPublishManifest ( ) ) ;
179172
180173 AssertPublishAssets (
181- StaticWebAssetsManifest . FromJsonBytes ( File . ReadAllBytes ( path ) ) ,
174+ manifest ,
182175 publishPath ,
183176 intermediateOutputPath ) ;
184177 }
185178
186- [ Fact ]
179+ [ Fact ( Skip = "https://github.com/dotnet/sdk/issues/29111" ) ]
187180 public void StaticWebAssets_HostedApp_ReferencingNetStandardLibrary_Works ( )
188181 {
189182 // Arrange
@@ -221,32 +214,14 @@ public void StaticWebAssets_HostedApp_ReferencingNetStandardLibrary_Works()
221214 new FileInfo ( path ) . Should ( ) . Exist ( ) ;
222215 var manifest = StaticWebAssetsManifest . FromJsonBytes ( File . ReadAllBytes ( path ) ) ;
223216
224- // We have to special case this test given we are forcing `blazorwasm` to be a `net5` project above.
225- // Given this, the `dotnet.*.js` file produced will be a dotnet.5.*.*.js file in line with the TFM and not the SDK (which is .NET 6 or beyond).
226- // This conflicts with our assumptions throughout the rest of the test suite that the SDK version matches the TFM.
227- // To minimize special casing throughout the entire test suite, we just update this particular test's assets to reflect the SDK version.
228- var numFilesUpdated = 0 ;
229- foreach ( var f in manifest . Assets )
230- {
231- if ( Regex . Match ( f . RelativePath , DotNet5JSRegexPattern ) . Success )
232- {
233- f . Identity = Regex . Replace ( f . Identity , DotNet5JSRegexPattern , DotNet5JSTemplate ) ;
234- f . RelativePath = Regex . Replace ( f . RelativePath , DotNet5JSRegexPattern , DotNet5JSTemplate ) ;
235- f . OriginalItemSpec = Regex . Replace ( f . OriginalItemSpec , DotNet5JSRegexPattern , DotNet5JSTemplate ) ;
236-
237- numFilesUpdated ++ ;
238- }
239- }
240- Assert . Equal ( 2 , numFilesUpdated ) ;
241-
242217 AssertManifest ( manifest , LoadBuildManifest ( ) ) ;
243218
244219 // GenerateStaticWebAssetsManifest should copy the file to the output folder.
245220 var finalPath = Path . Combine ( outputPath , "blazorhosted.staticwebassets.runtime.json" ) ;
246221 new FileInfo ( finalPath ) . Should ( ) . Exist ( ) ;
247222
248223 AssertBuildAssets (
249- StaticWebAssetsManifest . FromJsonBytes ( File . ReadAllBytes ( path ) ) ,
224+ manifest ,
250225 outputPath ,
251226 intermediateOutputPath ) ;
252227 }
@@ -293,27 +268,10 @@ public void StaticWebAssets_BackCompatibilityPublish_Hosted_Works()
293268 new FileInfo ( path ) . Should ( ) . Exist ( ) ;
294269 var manifest = StaticWebAssetsManifest . FromJsonBytes ( File . ReadAllBytes ( path ) ) ;
295270
296- // We have to special case this test given we are forcing `blazorwasm` to be a `net5` project above.
297- // Given this, the `dotnet.*.js` file produced will be a dotnet.5.*.*.js file in line with the TFM and not the SDK (which is .NET 6 or beyond).
298- // This conflicts with our assumptions throughout the rest of the test suite that the SDK version matches the TFM.
299- // To minimize special casing throughout the entire test suite, we just update this particular test's assets to reflect the SDK version.
300- var numFilesUpdated = 0 ;
301- var frameworkFolder = Path . Combine ( publishPath , "wwwroot" , "_framework" ) ;
302- var frameworkFolderFiles = Directory . GetFiles ( frameworkFolder , "*" , new EnumerationOptions { RecurseSubdirectories = false } ) ;
303- foreach ( var f in frameworkFolderFiles )
304- {
305- if ( Regex . Match ( f , DotNet5JSRegexPattern ) . Success )
306- {
307- File . Move ( f , Regex . Replace ( f , DotNet5JSRegexPattern , DotNet5JSTemplate ) ) ;
308- numFilesUpdated ++ ;
309- }
310- }
311- Assert . Equal ( 3 , numFilesUpdated ) ;
312-
313271 AssertManifest ( manifest , LoadPublishManifest ( ) ) ;
314272
315273 AssertPublishAssets (
316- StaticWebAssetsManifest . FromJsonBytes ( File . ReadAllBytes ( path ) ) ,
274+ manifest ,
317275 publishPath ,
318276 intermediateOutputPath ) ;
319277 }
0 commit comments