diff --git a/src/Components/WebAssembly/Sdk/integrationtests/WasmBuildIntegrationTest.cs b/src/Components/WebAssembly/Sdk/integrationtests/WasmBuildIntegrationTest.cs index c521c6be7e..0f109465ad 100644 --- a/src/Components/WebAssembly/Sdk/integrationtests/WasmBuildIntegrationTest.cs +++ b/src/Components/WebAssembly/Sdk/integrationtests/WasmBuildIntegrationTest.cs @@ -14,6 +14,29 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { private static readonly string DotNetJsFileName = $"dotnet.{BuildVariables.MicrosoftNETCoreAppRuntimeVersion}.js"; + [Fact] + public async Task BuildMinimal_Works() + { + // Arrange + // Minimal has no project references, service worker etc. This is pretty close to the project template. + using var project = ProjectDirectory.Create("blazorwasm-minimal"); + var result = await MSBuildProcessManager.DotnetMSBuild(project); + + Assert.BuildPassed(result); + + var buildOutputDirectory = project.BuildOutputDirectory; + + Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "blazor.boot.json"); + Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "blazor.webassembly.js"); + Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "dotnet.wasm"); + Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "dotnet.wasm.gz"); + Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", DotNetJsFileName); + Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "blazorwasm-minimal.dll"); + + var staticWebAssets = Assert.FileExists(result, buildOutputDirectory, "blazorwasm-minimal.StaticWebAssets.xml"); + Assert.FileContains(result, staticWebAssets, Path.Combine(project.TargetFramework, "wwwroot")); + } + [Fact] public async Task Build_Works() { diff --git a/src/Components/WebAssembly/Sdk/integrationtests/WasmPublishIntegrationTest.cs b/src/Components/WebAssembly/Sdk/integrationtests/WasmPublishIntegrationTest.cs index 1108d0bff9..590153a114 100644 --- a/src/Components/WebAssembly/Sdk/integrationtests/WasmPublishIntegrationTest.cs +++ b/src/Components/WebAssembly/Sdk/integrationtests/WasmPublishIntegrationTest.cs @@ -17,6 +17,35 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { private static readonly string DotNetJsFileName = $"dotnet.{BuildVariables.MicrosoftNETCoreAppRuntimeVersion}.js"; + [Fact] + public async Task Publish_MinimalApp_Works() + { + // Arrange + using var project = ProjectDirectory.Create("blazorwasm-minimal"); + var result = await MSBuildProcessManager.DotnetMSBuild(project, "Publish"); + + Assert.BuildPassed(result); + + var publishDirectory = project.PublishOutputDirectory; + + var blazorPublishDirectory = Path.Combine(publishDirectory, "wwwroot"); + + Assert.FileExists(result, blazorPublishDirectory, "_framework", "blazor.boot.json"); + Assert.FileExists(result, blazorPublishDirectory, "_framework", "blazor.webassembly.js"); + Assert.FileExists(result, blazorPublishDirectory, "_framework", "dotnet.wasm"); + Assert.FileExists(result, blazorPublishDirectory, "_framework", DotNetJsFileName); + Assert.FileExists(result, blazorPublishDirectory, "_framework", "blazorwasm-minimal.dll"); + + // Verify static assets are in the publish directory + Assert.FileExists(result, blazorPublishDirectory, "index.html"); + + // Verify web.config + Assert.FileExists(result, publishDirectory, "web.config"); + Assert.FileCountEquals(result, 1, publishDirectory, "*", SearchOption.TopDirectoryOnly); + + VerifyBootManifestHashes(result, blazorPublishDirectory); + } + [Fact] public async Task Publish_WithDefaultSettings_Works() { diff --git a/src/Components/WebAssembly/Sdk/src/targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets b/src/Components/WebAssembly/Sdk/src/targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets index a11bc00625..f0b8941d12 100644 --- a/src/Components/WebAssembly/Sdk/src/targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets +++ b/src/Components/WebAssembly/Sdk/src/targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets @@ -32,7 +32,7 @@ Copyright (c) .NET Foundation. All rights reserved. - $(MSBuildThisFileDirectory)..\..\ + $(MSBuildThisFileDirectory)..\ <_BlazorWebAssemblySdkTasksTFM Condition=" '$(MSBuildRuntimeType)' == 'Core'">net5.0 <_BlazorWebAssemblySdkTasksTFM Condition=" '$(MSBuildRuntimeType)' != 'Core'">net46 <_BlazorWebAssemblySdkTasksAssembly>$(BlazorWebAssemblySdkDirectoryRoot)tasks\$(_BlazorWebAssemblySdkTasksTFM)\Microsoft.NET.Sdk.BlazorWebAssembly.Tasks.dll @@ -69,7 +69,7 @@ Copyright (c) .NET Foundation. All rights reserved. - + + + + + false + + + + + $(RepoRoot)artifacts\bin\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib\$(Configuration)\netstandard2.0\ + + + + + + + + + + diff --git a/src/Components/WebAssembly/Sdk/testassets/blazorwasm-minimal/wwwroot/css/app.css b/src/Components/WebAssembly/Sdk/testassets/blazorwasm-minimal/wwwroot/css/app.css new file mode 100644 index 0000000000..fc64a12376 --- /dev/null +++ b/src/Components/WebAssembly/Sdk/testassets/blazorwasm-minimal/wwwroot/css/app.css @@ -0,0 +1 @@ +.build { } diff --git a/src/Components/WebAssembly/Sdk/testassets/blazorwasm-minimal/wwwroot/index.html b/src/Components/WebAssembly/Sdk/testassets/blazorwasm-minimal/wwwroot/index.html new file mode 100644 index 0000000000..bbfa66c41a --- /dev/null +++ b/src/Components/WebAssembly/Sdk/testassets/blazorwasm-minimal/wwwroot/index.html @@ -0,0 +1,24 @@ + + + + + + + standalone + + + + + + + Loading... + +
+ An unhandled error has occurred. + Reload + 🗙 +
+ + + +