-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Fix Blazor WASM SDK bugs #24172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Blazor WASM SDK bugs #24172
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ Copyright (c) .NET Foundation. All rights reserved. | |
|
||
<PropertyGroup> | ||
<!-- Paths to tools, tasks, and extensions are calculated relative to the BlazorWebAssemblySdkDirectoryRoot. This can be modified to test a local build. --> | ||
<BlazorWebAssemblySdkDirectoryRoot Condition="'$(BlazorWebAssemblySdkDirectoryRoot)'==''">$(MSBuildThisFileDirectory)..\..\</BlazorWebAssemblySdkDirectoryRoot> | ||
<BlazorWebAssemblySdkDirectoryRoot Condition="'$(BlazorWebAssemblySdkDirectoryRoot)'==''">$(MSBuildThisFileDirectory)..\</BlazorWebAssemblySdkDirectoryRoot> | ||
<_BlazorWebAssemblySdkTasksTFM Condition=" '$(MSBuildRuntimeType)' == 'Core'">net5.0</_BlazorWebAssemblySdkTasksTFM> | ||
<_BlazorWebAssemblySdkTasksTFM Condition=" '$(MSBuildRuntimeType)' != 'Core'">net46</_BlazorWebAssemblySdkTasksTFM> | ||
<_BlazorWebAssemblySdkTasksAssembly>$(BlazorWebAssemblySdkDirectoryRoot)tasks\$(_BlazorWebAssemblySdkTasksTFM)\Microsoft.NET.Sdk.BlazorWebAssembly.Tasks.dll</_BlazorWebAssemblySdkTasksAssembly> | ||
|
@@ -69,7 +69,7 @@ Copyright (c) .NET Foundation. All rights reserved. | |
|
||
</PropertyGroup> | ||
|
||
<Import Project="Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.targets" /> | ||
<Import Project="Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.targets" Condition="'$(ServiceWorkerAssetsManifest)' != ''" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Our test app always had a service worker. Importing this was causing issues in a project that did not have a service worker. I added build and publish tests for an app that's closer to our standalone template. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious: what issues did it cause for projects that didn't have service workers? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The targets unconditionally run when the file is imported: https://github.com/dotnet/aspnetcore/blob/master/src/Components/WebAssembly/Sdk/src/targets/Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.targets#L16. This results in spooky errors because it assumes a manifest file exists |
||
|
||
<Target Name="_ScrambleDotnetJsFileName" AfterTargets="ResolveRuntimePackAssets"> | ||
<!-- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Router AppAssembly="@typeof(Program).Assembly"> | ||
<Found Context="routeData"> | ||
<RouteView RouteData="@routeData"/> | ||
</Found> | ||
<NotFound> | ||
<p>Sorry, there's nothing at this address.</p> | ||
</NotFound> | ||
</Router> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@page "/" | ||
|
||
<h1>Hello, world!</h1> | ||
|
||
Welcome to your new app. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
|
||
namespace standalone | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@using Microsoft.AspNetCore.Components.Routing | ||
@using standalone |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Razor"> | ||
|
||
<Import Project="$(RepoRoot)src\Components\WebAssembly\Sdk\src\Sdk\Sdk.props" /> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net5.0</TargetFramework> | ||
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier> | ||
<RazorSdkDirectoryRoot>$(RazorSdkArtifactsDirectory)$(Configuration)\sdk-output\</RazorSdkDirectoryRoot> | ||
<BlazorWebAssemblySdkDirectoryRoot>$(BlazorWebAssemblySdkArtifactsDirectory)$(Configuration)\sdk-output\</BlazorWebAssemblySdkDirectoryRoot> | ||
</PropertyGroup> | ||
|
||
<!-- Test Placeholder --> | ||
|
||
<PropertyGroup Condition="'$(RunningAsTest)' == ''"> | ||
<!-- We don't want to run build server when not running as tests. --> | ||
<UseRazorBuildServer>false</UseRazorBuildServer> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(BinariesRoot)'==''"> | ||
<!-- In test scenarios $(BinariesRoot) is defined in a generated Directory.Build.props file --> | ||
<BinariesRoot>$(RepoRoot)artifacts\bin\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib\$(Configuration)\netstandard2.0\</BinariesRoot> | ||
</PropertyGroup> | ||
|
||
<!-- DO NOT add addition references here. This is meant to simulate a non-MVC library --> | ||
<ItemGroup Condition="'$(BinariesRoot)'!=''"> | ||
<Reference Include="$(BinariesRoot)\Microsoft.AspNetCore.Razor.Test.ComponentShim.dll"/> | ||
</ItemGroup> | ||
|
||
<Import Project="$(RepoRoot)src\Components\WebAssembly\Sdk\src\Sdk\Sdk.targets" /> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.build { } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>standalone</title> | ||
<base href="/" /> | ||
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" /> | ||
<link href="css/app.css" rel="stylesheet" /> | ||
</head> | ||
|
||
<body> | ||
<app>Loading...</app> | ||
|
||
<div id="blazor-error-ui"> | ||
An unhandled error has occurred. | ||
<a href="" class="reload">Reload</a> | ||
<a class="dismiss">🗙</a> | ||
</div> | ||
<script src="_framework/blazor.webassembly.js"></script> | ||
</body> | ||
|
||
</html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our integration tests run from the build output and do not exercise this code path. Our templates will once we have a .NET SDK that includes the Blazor SDK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When will we be doing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to insert the Blazor SDK -> .NET SDK -> Installer -> update our global.json to use this build -> Golden!