Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
324 stars 56 forks source link

.NET 6 Preview 4 & Blazor WASM AOT Compilation #452

Open Zhiyuan-Amos opened 3 years ago

Zhiyuan-Amos commented 3 years ago

Hello! When will .NET 6 Preview 4 be supported? Also, will AOT compilation be supported through some sort of configuration? 😄

anthonychu commented 3 years ago

This is blocked by: https://github.com/dotnet/sdk/issues/17865

A workaround is to run the build on Windows, like this: https://github.com/anthonychu/ConwayBlazor/blob/3460b8877f05a9bf099e2e473def3f45dc8924fd/.github/workflows/azure-static-web-apps-orange-sky-00add8710.yml

Looks like this will be fixed in Preview 5. Created an issue to see if Oryx can build this automatically when Preview 5 is out. https://github.com/microsoft/Oryx/issues/1026

Also added an issue to track updating Oryx to Preview 4. https://github.com/microsoft/Oryx/issues/1025

/cc @danroth27 @arroyc

qianz2 commented 3 years ago

@anthonychu We recently supported .NET preview 4, it should be available through dynamic installation now.

loganmarshall1 commented 2 years ago

Hi @anthonychu Im also trying to get this to work via Azure DevOps pipeline. Do you have any code snippets to help my YML?

Pipeline message ` Determining projects to restore... /tmp/oryx/platforms/dotnet/6.0.100-rc.2.21505.57/sdk/6.0.100-rc.2.21505.57/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To build this project, the following workloads must be installed: wasm-tools [/working_dir/AppMain/AppMain.csproj] /tmp/oryx/platforms/dotnet/6.0.100-rc.2.21505.57/sdk/6.0.100-rc.2.21505.57/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To install these workloads, run the following command: dotnet workload install wasm-tools [/working_dir/AppMain/AppMain.csproj]

---End of Oryx build logs--- Oryx has failed to build the solution. `

Current YML `trigger: branches: include:

pool: vmImage: ubuntu-latest

steps:

Thanks!

anthonychu commented 2 years ago

You can now deploy .NET 6 Blazor WebAssembly apps, including those that use AOT, to Azure Static Web Apps! Blazor WebAssembly is automatically detected and the wasm-tools workload is automatically installed. See blog post for more information.

loganmarshall1 commented 2 years ago

Fantastic this is amazing going to try it out in production right now :)

loganmarshall1 commented 2 years ago

Hi @anthonychu

Works Great! 1 more question... ;)... Current Azure DevOps message is...

Oryx has timed out while building app, the current limit is 15 minutes. Failing build.

AOT'd 154 dlls, is there anyway that I can Opt out of certain dlls from AOT? like ones that take long to help?

is there a setting in .csproj? currently my csproj states...

`

True

`

anthonychu commented 2 years ago

We've added an input parameter build_timeout_in_minutes to the task that should be rolling out during this month. Not sure if it's widely available yet to all DevOps customers.

I don't know if there's a way to opt out of certain DLLs. @danroth27 any ideas here?

loganmarshall1 commented 2 years ago

Thank you @anthonychu ! will it be a param here: image

Hi @danroth27 , long time fan of yours! nice to meet you! wow so happy that I'm on a thread your tagged in! makes me feel like "Waynes World" "Im not worthy" :D. <3 what you do, your positivity and continued smart drive which is helping all developers everywhere! Please let @anthonychu and I know if there's a csproj 'switch' that exists? if not, no action needed in my case as the Input Parameter that @anthonychu mentioned should be perfect for this! thanks kindly!

danroth27 commented 2 years ago

AOT'd 154 dlls, is there anyway that I can Opt out of certain dlls from AOT? like ones that take long to help?

Not yet. Having a mixture of AOT compiled code and normal assemblies is tricky for the runtime to handle, so for .NET 6 the only supported configuration is to AOT compile everything to WebAssembly.

loganmarshall1 commented 2 years ago

Hi @danroth27 thanks for your quick reply!

FYI (Tuesday) we just pushed 7 Blazor wasm PWAs to Production on Dotnet 6 and customers are LOVING IT! They said they noticed "30% speed improvements" EVERYWHERE! :D . Our apps currently have over Average ~ 10k users per 7 apps.

Currently for the Trimmer I've added this to CSPROJ `

`

Which helped for "trimming unused assemblies" i believe ;) . Maybe a CSPROJ Switch as all thats needed for a future proof AOT?

perhaps, `

True
<RunAOTCompilation Exclude="SomeHuge.Big.Maybe.SuperHuge.Dll">False</RunAOTCompilation>

`

Oh by the Way, you and @anthonychu , and everyone else are doing so great! you inspire tons of DEVs everyday and We ALL love you positive, smart, upbeat personality! <3

danroth27 commented 2 years ago

FYI (Tuesday) we just pushed 7 Blazor wasm PWAs to Production on Dotnet 6 and customers are LOVING IT! They said they noticed "30% speed improvements" EVERYWHERE! :D . Our apps currently have over Average ~ 10k users per 7 apps.

That's awesome! Great to hear! If you're open to us sharing your story with using .NET & Blazor on our .NET Customers page, you can share your story with us using this form.

Currently for the Trimmer I've added this to CSPROJ <ItemGroup> <TrimmerRootAssembly Include="Microsoft.Authentication.WebAssembly.Msal" /> </ItemGroup> Which helped for "trimming unused assemblies" i believe ;) .

Doesn't marking Microsoft.Authentication.WebAssembly.Msal as a root assembly mean that it doesn't get trimmed at all? Is that what you intended to do?

loganmarshall1 commented 2 years ago

Will do! Thanks Dan!!!!

Yes completely intended! apparently it was a workaround needed when .net 6 preview x came out. MSAL Was getting overly trimmed to the point that blazor wasm auth didn't work. i'm sure I can take this out of the file now since .NET 6 is now GA 😄

The big thing with CSPROJ file temp fixes Is they kind of "live in there" for years and no one knows whether or not they can take them out.

Github or a stack overflow fix suggests... "Oh just put this in your CSPROJ" 😅

The great news is that a lot of these fixes work right away 👍

I would love to get your feedback on everyone that has put in things in there CSPROJ as 'workarounds', and how do we inform customers on you can take it out now?

I wonder if it's just regular a .net developer email communication that says "hey if you put these things in your Csprojfile before as a temp fix, you don't need to have them in there anymore"

even better yet do we have analyzers on ".CSPROJ"? I think I just blew my own mind 😂

analyzer would state "this you added currently does absolutely nothing would you like to remove?" 😊

perhaps they're just benign and don't affect things. I for one love clean perfect code and I definitely appreciate knowing that everything is ONLY there for a reason. :)

thanks again for your quick response. I keep on getting good feedback about you and everyone on the team!

DaleCam commented 9 months ago

Hi there, I still have this issue in dot net 8.0.100. This maybe the same issue?: https://github.com/Azure/static-web-apps/issues/1334

When using YAML to publish to Azure Static Web Apps, i get the same error:

Using .NET Core SDK Version: 8.0.100 "2023-12-01 20:14:11"|ERROR| Determining projects to restore... /opt/dotnet/8.0.100/sdk/8.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To build this project, the following workloads must be installed: wasm-tools [/working_dir/Deckhand.Mobile/Mobile.Pwa/Mobile.Pwa.csproj] /opt/dotnet/8.0.100/sdk/8.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To install these workloads, run the following command: dotnet workload restore [/working_dir/Deckhand.Mobile/Mobile.Pwa/Mobile.Pwa.csproj] | 1 | Please build your app locally before publishing. | https://docs.microsoft.com/en-us/azure/app-service/configure-language-dotnetcore?pivots=platform-linux

---End of Oryx build logs--- Oryx build has completed. Took 32.5293328 seconds. Exit Code: 1 Oryx has failed to build the solution.

The YAML im using: jobs:

thomasgauvin commented 9 months ago

@dalecam we're working on the fix for this for Blazor & .NET 8, keeping the other thread updated https://github.com/Azure/static-web-apps/issues/1334

DaleCam commented 6 months ago

My company is desperately needing AOT for our blazor dotnet 8 App that's being used by about 60,000 users. Is there any way this issue can be prioritised? In the meantime we will have to stop using Azure Static Web Apps for hosting until this is fixed. cc: @danroth27

danroth27 commented 6 months ago

@dalecam WebAssembly AOT should already be supported on Azure Static Web Apps. What issue are you hitting?

@thomasgauvin Should this issue be closed?

DaleCam commented 6 months ago

@danroth27 - There is a thread with more information here: https://github.com/Azure/static-web-apps/issues/1334#issuecomment-1810463688 It wasn't building with AOT for the last few months, however I tried the pipeline again today and its now working! So please ignore this! Thank you for your prompt reply - much appreciated.