-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Replat blazor on net5 #23078
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
Replat blazor on net5 #23078
Conversation
23f896d
to
3caf917
Compare
@@ -1,16 +0,0 @@ | |||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
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.
I didn't bring this app forward. It seems low value and requires additional work to get the loader script functioning. Let me know if you feel strongly about keeping 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.
I think it's great to remove this 👍
This project (and its tests) was created before Blazor, so we had some way to make sense of how .NET code should behave on WebAssembly, and so that if the runtime behaviors around low-level basics like exception handling, boxing, etc. varied then we'd have a way to observe that objectively.
By now, .NET on WebAssembly is well enough established that we don't have to get independent proof that the low-level basics work correctly!
...mponents/WebAssembly/testassets/Wasm.Authentication.Server/Wasm.Authentication.Server.csproj
Outdated
Show resolved
Hide resolved
@@ -63,13 +63,13 @@ protected override void InitializeAsyncCore() | |||
WaitUntilLoaded(); | |||
} | |||
|
|||
[Fact] | |||
[Fact(Skip = "https://github.com/dotnet/runtime/issues/38098")] |
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.
Async JSInterop code paths are busted because TCS.SetResult throws
|
||
namespace Microsoft.AspNetCore.Razor.Tasks | ||
{ | ||
public partial class GenerateServiceWorkerAssetsManifest : Task |
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.
Similar to boot.json, we operate on a different set of inputs during build and publish. This task has been modified to do what was previously done across multiple msbuild targets. I need to spend a little bit of time to verify, but it should be just as incremental as before.
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.
That's great. Do you feel the test coverage we have for this is adequate? We've had multiple regressions related to SWAM and build/publish/incrementalism, perhaps because it's pretty hard to tell whether it's right just by casually running an app.
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.
I retained all the tests from before. My plan's to go over these again and see if there are gaps and see if we could have more combination of tests (VS-style publish + build incrementalism for instance)
...rosoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.CodeGeneration.targets
Show resolved
Hide resolved
@@ -513,7 +513,7 @@ Copyright (c) .NET Foundation. All rights reserved. | |||
--> | |||
<_ExternalPublishStaticWebAsset | |||
Include="%(StaticWebAsset.FullPath)" | |||
Condition="'%(SourceType)' != ''"> | |||
Condition="'%(SourceType)' != '' AND '%(StaticWebAsset.CopyToPublishDirectory)' != 'Never'"> |
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 don't want assets such as the boot.json produced during build to be copied to the publish directory. There was a bug in these targets where it wouldn't honor the CopyToPublishDirectory setting.
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 shouldn't leave random stuff in the SWA definition. What problem are we trying to solve here? I'm not sure what boot.json you are referring to, blazor.boot.json
? How is that not going to be an SWA?
@@ -14,4 +14,5 @@ Copyright (c) .NET Foundation. All rights reserved. | |||
<RazorSdkCurrentVersionProps>$(MSBuildThisFileDirectory)Sdk.Razor.CurrentVersion.props</RazorSdkCurrentVersionProps> | |||
<RazorSdkCurrentVersionTargets>$(MSBuildThisFileDirectory)Sdk.Razor.CurrentVersion.targets</RazorSdkCurrentVersionTargets> | |||
</PropertyGroup> | |||
</Project> | |||
|
|||
</Project> |
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.
Will undo
@@ -354,6 +356,8 @@ Copyright (c) .NET Foundation. All rights reserved. | |||
|
|||
<Import Project="Microsoft.NET.Sdk.Razor.MvcApplicationPartsDiscovery.targets" Condition="'$(_TargetingNETCoreApp30OrLater)' == 'true'" /> | |||
|
|||
<Import Project="Microsoft.NET.Sdk.Razor.Components.Wasm.targets" Condition="'$(_TargetingNET50OrLater)' == 'true' AND '$(UseBlazorWebAssembly)' == 'true'" /> |
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.
This target gets imported far too late to set up useful defaults such as RuntimeIdentifier
or the flag that tells the SDK not to append the rid to the output path. We are able to do other things such as tell it to not reference M.AspNetCore.App or do trimmed publish. One way to remedy the evaluation order issue is to add a blazor-wasm specific SDK.
3caf917
to
5cbfd78
Compare
👀 |
775b2b2
to
f6a0514
Compare
eng/Versions.props
Outdated
@@ -66,69 +66,69 @@ | |||
<!-- Packages from dotnet/roslyn --> | |||
<MicrosoftNetCompilersToolsetPackageVersion>3.7.0-4.20319.6</MicrosoftNetCompilersToolsetPackageVersion> | |||
<!-- Packages from dotnet/runtime --> | |||
<MicrosoftExtensionsDependencyModelPackageVersion>5.0.0-preview.7.20321.2</MicrosoftExtensionsDependencyModelPackageVersion> |
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.
Please ignore. I'll rebase this once darc updates this file. Using this to verify that the latest build resolves outstanding issues with the wasm runtime.
@pranavkm I got added as a reviewer due to code ownership I believe. And, you're going to revert the changes to the file I kinda own. Is there anything here you'd like me to review? Curiosity only: Does this help move us any closer to archiving the dotnet/blazor repo? |
<FixupWebAssemblyHttpHandlerReference>true</FixupWebAssemblyHttpHandlerReference> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="Microsoft.AspNetCore.Components.WebAssembly" /> | ||
<Reference Include="System.Net.Http.Json" /> | ||
|
||
<FrameworkReference Remove="Microsoft.AspNetCore.App" /> |
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.
Could you explain what this <FrameworkReference>
is for? Since StandaloneApp
runs on WebAssembly, I wouldn't expect there to be references to anything from server-side ASP.NET Core.
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.
This could be removed from the project file since the SDK removes this for you. The project targets the WebSDK and net5.0, you get an implicit reference to this framework. I filed #23259 to figure out a better way to do this.
src/Components/test/testassets/BasicTestApp/wwwroot/js/jsinteroptests.js
Outdated
Show resolved
Hide resolved
src/ProjectTemplates/BlazorTemplates.Tests/BlazorWasmTemplateTest.cs
Outdated
Show resolved
Hide resolved
src/ProjectTemplates/BlazorTemplates.Tests/BlazorWasmTemplateTest.cs
Outdated
Show resolved
Hide resolved
src/Razor/Microsoft.AspNetCore.Razor.Tools/src/BrotliCompressCommand.cs
Outdated
Show resolved
Hide resolved
{ | ||
Sources = Option("-s", ".cshtml files to compile", CommandOptionType.MultipleValue); | ||
Outputs = Option("-o", "Generated output file path", CommandOptionType.MultipleValue); | ||
CompressionLevelOption = Option("-c", "Compression level", CommandOptionType.SingleValue); |
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.
I don't really feel strongly about removing this, but I'm not aware we have any use case for having an option. We always want to use max AFAIK.
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.
They get turned down in the Razor integration tests. It makes the tests take far too long if they perform maximal compression every time.
Assert.Null(bootJsonData.resources.satelliteResources); | ||
} | ||
|
||
[Fact(Skip = "https://github.com/dotnet/aspnetcore/issues/22975")] |
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.
To be tracked
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.
This one's our issue.
src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/Wasm/WasmBuildIntegrationTest.cs
Show resolved
Hide resolved
@@ -19,6 +13,8 @@ | |||
<type fullname="System.ComponentModel.TimeSpanConverter" /> | |||
</assembly> | |||
|
|||
<assembly fullname="System.Runtime.InteropServices.JavaScript" preserve="all" /> | |||
|
|||
<assembly fullname="System.Text.Json"> |
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 might be able to drop this now (as it was working around an issue in STJ that might be fixed). Perfectly fine if you don't want to mess with extra stuff in this PR of course though!
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.
I filed #23262 to see if we can get these resolved by the BCL.
.../build/netstandard2.0/Microsoft.NET.Sdk.Razor.Components.ServiceWorkerAssetsManifest.targets
Show resolved
Hide resolved
@@ -0,0 +1,482 @@ | |||
<!-- |
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.
Since there's no diff associated with this file, it's pretty hard to CR and reason about what's changing.
Do you think you'd be able to summarize the high-level points about what's being done differently here now?
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.
The "Build" part of the pipeline is pretty close to what we had in Blazor.MonoRuntime.targets. We gather inputs, generate a blazor.boot.json, optionally a server worker manifest, add things to StaticWebAssets, and copy files to $(OutputPath)wwwroot
. We no longer run the linker or compression during, so those parts of the pipeline are removed.
When publishing standalone, the linker operates on ResolvedFileToPublish
. These files are inputs to compression, published PWA manifest, and the published blazor.boot.json. It's pretty much like build, but with different inputs. To make our lives easier, rather than the targets calculating values (such as BootManifestResourceType
), the tasks do it. This saves us from duplicating a lot of MSBuild code between the build and publish targets.
Publishing P2P is a bit more interesting. A dotnet publish
on a hosted server project, only results in a dotnet build
on the referenced client project. This is how MSBuild works. But we want this to produce a "published" WASM app. There is an escape hatch though. MSBuild also calls GetCopyToPublishDirectoryItems
on referenced projects to get files to copy to the server's outputs. We use this to do a publish on the client project and copy them over to the server.
{ | ||
[Fact] | ||
[Fact(Skip = "TODO fix 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.
Not sure if you're planning to handle this as part of the PR or later. If later, could you add it to the list of things to be tracked for follow-up? Presumably we could have one big issue listing them all.
@@ -26,6 +27,9 @@ | |||
|
|||
<!-- Working around an issue in XDT transforms --> | |||
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel> | |||
|
|||
<!-- Turn down the compression level for brotli --> | |||
<_BlazorBrotliCompressionLevel>NoCompression</_BlazorBrotliCompressionLevel> |
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.
Why? To make CI builds faster? Does it make enough of a difference to be worthwhile?
Also, our benchmarking relies on getting realistic brotli-compressed sizes. Just want to check this isn't going to interfere.
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.
This is specifically for the integration tests. It takes kinda long: #21382
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.
This is looking really great! Thanks for figuring out all these details. It's cool to see things getting simpler as part of this process.
Not sure how close you are to considering this PR done so I'll await a further ping when you're ready for sign-off.
<!-- Disable compression in this project so that we can validate that it can be disabled --> | ||
<BlazorEnableCompression>false</BlazorEnableCompression> | ||
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework> | ||
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier> |
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.
Did we get around the publish hosted bit by forcing the RID?
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.
I thought I'd tried this, but there's an issue where dotnet publish -r [rid]
doesn't work. The restore that runs as part of publish messes things up. I'll talk to SDK folks about this and see what they recommend doing here.
var razorSDKarg = string.IsNullOrEmpty(RazorSdkDirectoryRoot) ? string.Empty : $"/p:RazorSdkDirectoryRoot={RazorSdkDirectoryRoot}"; | ||
|
||
using var result = ProcessEx.Run(Output, TemplateOutputDir, DotNetMuxer.MuxerPathOrDefault(), $"build --no-restore -c Debug /bl {razorSDKarg} {additionalArgs}", packageOptions); | ||
using var result = ProcessEx.Run(Output, TemplateOutputDir, DotNetMuxer.MuxerPathOrDefault(), $"build --no-restore -c Debug /bl {additionalArgs}", packageOptions); |
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.
Why do we need the rid now here?
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.
Further up? WASM produces outputs in a RID based directory. There's a flag to turn it off, but does not work: dotnet/sdk#12114
@@ -39,6 +39,7 @@ internal class Application : CommandLineApplication | |||
Commands.Add(new ShutdownCommand(this)); | |||
Commands.Add(new DiscoverCommand(this)); | |||
Commands.Add(new GenerateCommand(this)); | |||
Commands.Add(new BrotliCompressCommand(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.
Does this ties compression to the Razor compiler?
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.
To the rzc tool, but it does not remote calls to the server process. It doesn't seem problematic as yet, but we can come back to this if there are side-effects to it.
@@ -269,7 +269,7 @@ Copyright (c) .NET Foundation. All rights reserved. | |||
<ItemGroup> | |||
<StaticWebAsset | |||
Include="@(_ReferencedProjectStaticWebAssets)" | |||
KeepMetadata="ContentRoot;BasePath;RelativePath;SourceId;SourceType" /> | |||
KeepMetadata="ContentRoot;BasePath;RelativePath;SourceId;SourceType;CopyToPublishDirectory" /> |
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.
SWAs should only have ContentRoot;BasePath;RelativePath;SourceId;SourceType
I want to avoid them becoming a random bag of properties.
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.
Looks great!
I want us to discuss the issue with SWA, but other than that looks fine.
f6a0514
to
e7c1ced
Compare
…0622.6 System.ComponentModel.Annotations , System.Diagnostics.DiagnosticSource , System.Diagnostics.EventLog , Microsoft.Extensions.Logging.Configuration , Microsoft.Extensions.Logging.Console , Microsoft.Extensions.Logging.Debug , Microsoft.Extensions.Logging.EventLog , Microsoft.Extensions.Logging.EventSource , Microsoft.Extensions.Logging.TraceSource , Microsoft.Extensions.Options , Microsoft.Extensions.Options.ConfigurationExtensions , Microsoft.Extensions.Options.DataAnnotations , Microsoft.Extensions.Primitives , Microsoft.Extensions.Logging.Abstractions , Microsoft.Extensions.Logging , Microsoft.Extensions.Internal.Transport , Microsoft.Extensions.Http , Microsoft.Extensions.Caching.Abstractions , Microsoft.Extensions.Caching.Memory , Microsoft.Extensions.Configuration , Microsoft.Extensions.Configuration.Abstractions , Microsoft.Extensions.Configuration.Binder , Microsoft.Extensions.Configuration.CommandLine , Microsoft.Extensions.Configuration.EnvironmentVariables , Microsoft.Extensions.Configuration.FileExtensions , Microsoft.Extensions.Configuration.Ini , Microsoft.Extensions.Configuration.Json , Microsoft.Extensions.Configuration.UserSecrets , Microsoft.Extensions.DependencyInjection , Microsoft.Extensions.DependencyInjection.Abstractions , Microsoft.Extensions.DependencyModel , Microsoft.Extensions.FileProviders.Abstractions , Microsoft.Extensions.FileProviders.Composite , Microsoft.Extensions.FileProviders.Physical , Microsoft.Extensions.FileSystemGlobbing , Microsoft.Extensions.HostFactoryResolver.Sources , Microsoft.Extensions.Hosting , Microsoft.Extensions.Hosting.Abstractions , Microsoft.Extensions.Configuration.Xml , Microsoft.NETCore.App.Runtime.win-x64 , Microsoft.NETCore.Platforms , Microsoft.Win32.Registry , Microsoft.Win32.SystemEvents , Microsoft.NETCore.App.Internal , Microsoft.NETCore.App.Ref , System.Drawing.Common , System.ServiceProcess.ServiceController , System.Text.Encodings.Web , System.Text.Json , System.Threading.Channels , System.Windows.Extensions , System.Security.Principal.Windows , System.Security.Permissions , System.Security.Cryptography.Xml , System.IO.Pipelines , System.Net.Http.Json , System.Net.Http.WinHttpHandler , System.Net.WebSockets.WebSocketProtocol , System.Reflection.Metadata , System.Runtime.CompilerServices.Unsafe , System.Security.Cryptography.Cng , System.Security.Cryptography.Pkcs From Version 5.0.0-preview.7.20321.2 -> To Version 5.0.0-preview.7.20322.6
e7c1ced
to
b7161e3
Compare
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.
Let's get this merged so we can unblock our partners.
Please address any follow-up feedback through separate PRs, as this is pretty large already.
Still need to get through some test issues, but the apps work now without issues and the sdk tests are passing locally.
Things pending
Scramble the dotnet.js file nameFigure out packing for blazor.webassembly.jsUpdate templates to net5The largest issue I noticed since the sync up today is that
RuntimeIdentifer
is required to be specified in the project file. The Razor SDK is imported too late to set this up correctly.I'm going to talk to the SDK folks to figure out how to not have this in the project file. Ignore that for now.We had a conversation with some folks about possibly having a Blazor WASM specific SDK. This should remedy the problem. I'll hold off on this for now.