From dbba347f20d2d56e3a23e41f2c03caf1b7dd9e17 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 9 Dec 2020 13:06:05 -0800 Subject: [PATCH] Provide a better error message if a blazorwasm app references ASP.NET Core (#28493) Fixes https://github.com/dotnet/aspnetcore/issues/28478 --- .../WasmBuildIntegrationTest.cs | 10 ++++++ ....NET.Sdk.BlazorWebAssembly.Current.targets | 7 +++++ .../RestoreBlazorWasmTestProjects.csproj | 1 + .../Sdk/testassets/blazorwasm-fxref/App.razor | 1 + .../testassets/blazorwasm-fxref/Program.cs | 11 +++++++ .../blazorwasm-fxref/blazorwasm-fxref.csproj | 31 +++++++++++++++++++ 6 files changed, 61 insertions(+) create mode 100644 src/Components/WebAssembly/Sdk/testassets/blazorwasm-fxref/App.razor create mode 100644 src/Components/WebAssembly/Sdk/testassets/blazorwasm-fxref/Program.cs create mode 100644 src/Components/WebAssembly/Sdk/testassets/blazorwasm-fxref/blazorwasm-fxref.csproj diff --git a/src/Components/WebAssembly/Sdk/integrationtests/WasmBuildIntegrationTest.cs b/src/Components/WebAssembly/Sdk/integrationtests/WasmBuildIntegrationTest.cs index 2a0e92fcc6..df9a036a84 100644 --- a/src/Components/WebAssembly/Sdk/integrationtests/WasmBuildIntegrationTest.cs +++ b/src/Components/WebAssembly/Sdk/integrationtests/WasmBuildIntegrationTest.cs @@ -335,6 +335,16 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.BuildPassed(result); } + [Fact] + public async Task Build_WithAspNetCoreFrameworkReference_Fails() + { + // Arrange + using var project = ProjectDirectory.Create("blazorwasm-fxref"); + + var result = await MSBuildProcessManager.DotnetMSBuild(project); + Assert.BuildError(result, "BLAZORSDK1001"); + } + private static BootJsonData ReadBootJsonData(MSBuildResult result, string path) { return JsonSerializer.Deserialize( 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 e1e0a3c807..d8be7b59b1 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 @@ -631,6 +631,13 @@ Copyright (c) .NET Foundation. All rights reserved. + + + + diff --git a/src/Components/WebAssembly/Sdk/testassets/RestoreBlazorWasmTestProjects/RestoreBlazorWasmTestProjects.csproj b/src/Components/WebAssembly/Sdk/testassets/RestoreBlazorWasmTestProjects/RestoreBlazorWasmTestProjects.csproj index 46b847139d..2af6c265d4 100644 --- a/src/Components/WebAssembly/Sdk/testassets/RestoreBlazorWasmTestProjects/RestoreBlazorWasmTestProjects.csproj +++ b/src/Components/WebAssembly/Sdk/testassets/RestoreBlazorWasmTestProjects/RestoreBlazorWasmTestProjects.csproj @@ -8,6 +8,7 @@ + diff --git a/src/Components/WebAssembly/Sdk/testassets/blazorwasm-fxref/App.razor b/src/Components/WebAssembly/Sdk/testassets/blazorwasm-fxref/App.razor new file mode 100644 index 0000000000..0c55cf88d2 --- /dev/null +++ b/src/Components/WebAssembly/Sdk/testassets/blazorwasm-fxref/App.razor @@ -0,0 +1 @@ +Hello from App \ No newline at end of file diff --git a/src/Components/WebAssembly/Sdk/testassets/blazorwasm-fxref/Program.cs b/src/Components/WebAssembly/Sdk/testassets/blazorwasm-fxref/Program.cs new file mode 100644 index 0000000000..3ebadb8b76 --- /dev/null +++ b/src/Components/WebAssembly/Sdk/testassets/blazorwasm-fxref/Program.cs @@ -0,0 +1,11 @@ +using System; + +namespace standalone +{ + public class Program + { + public static void Main(string[] args) + { + } + } +} diff --git a/src/Components/WebAssembly/Sdk/testassets/blazorwasm-fxref/blazorwasm-fxref.csproj b/src/Components/WebAssembly/Sdk/testassets/blazorwasm-fxref/blazorwasm-fxref.csproj new file mode 100644 index 0000000000..b9708e7e15 --- /dev/null +++ b/src/Components/WebAssembly/Sdk/testassets/blazorwasm-fxref/blazorwasm-fxref.csproj @@ -0,0 +1,31 @@ + + + + net5.0 + browser-wasm + $(RazorSdkArtifactsDirectory)$(Configuration)\sdk-output\ + $(BlazorWebAssemblySdkArtifactsDirectory)$(Configuration)\sdk-output\ + + + + + + + false + + + + + $(RepoRoot)artifacts\bin\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib\$(Configuration)\netstandard2.0\ + + + + + + + + + + + +