SteveSandersonMS / dotnet-wasi-sdk

Packages for building .NET projects as standalone WASI-compliant modules
518 stars 36 forks source link

Web app: System.Net.Quic is not supported on this platform. #12

Closed marinasundstrom closed 2 years ago

marinasundstrom commented 2 years ago

Followed the instructions for building a web app. While running the app I get this exception: System.Net.Quic is not supported on this platform.

I'm using .NET 7 SDK Preview 4.

Unhandled Exception:
System.PlatformNotSupportedException: System.Net.Quic is not supported on this platform.
   at System.Net.Quic.QuicImplementationProviders.get_Default()
   at Microsoft.AspNetCore.Hosting.WebHostBuilderQuicExtensions.UseQuic(IWebHostBuilder hostBuilder)
   at Microsoft.AspNetCore.Hosting.WebHostBuilderKestrelExtensions.UseKestrel(IWebHostBuilder hostBuilder)
   at Microsoft.AspNetCore.Hosting.WebHostBuilderKestrelExtensions.UseKestrel(IWebHostBuilder hostBuilder, Action`2 configureOptions)
   at Microsoft.AspNetCore.WebHost.ConfigureWebDefaults(IWebHostBuilder builder)
   at Microsoft.Extensions.Hosting.GenericHostBuilderExtensions.<>c__DisplayClass1_0.<ConfigureWebHostDefaults>b__0(IWebHostBuilder webHostBuilder)
   at Microsoft.Extensions.Hosting.GenericHostWebHostBuilderExtensions.ConfigureWebHost(IHostBuilder builder, Action`1 configure, Action`1 configureWebHostBuilder)
   at Microsoft.Extensions.Hosting.GenericHostBuilderExtensions.ConfigureWebHostDefaults(IHostBuilder builder, Action`1 configure, Action`1 configureOptions)
   at Microsoft.AspNetCore.Builder.WebApplicationBuilder..ctor(WebApplicationOptions options, Action`1 configureDefaults)
   at Microsoft.AspNetCore.Builder.WebApplication.CreateBuilder(String[] args)
   at Program.<Main>$(String[] args)

Program.cs:

var builder = WebApplication.CreateBuilder(args).UseWasiConnectionListener();

var app = builder.Build();

app.UseStaticFiles();

app.MapGet("/", () => "Hello World!");

app.Run();

.csproj:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

  <PropertyGroup>
    <WasiRunnerArgs>--tcplisten localhost:8080 --env ASPNETCORE_URLS=http://localhost:8080</WasiRunnerArgs>
  </PropertyGroup>

  <ItemGroup>
    <WasmBundleFiles Include="wwwroot\**" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Wasi.AspNetCore.BundledFiles" Version="0.1.0" />
    <PackageReference Include="Wasi.AspNetCore.Server.Native" Version="0.1.0" />
    <PackageReference Include="Wasi.Sdk" Version="0.1.0" />
  </ItemGroup>

</Project>
SteveSandersonMS commented 2 years ago

Thanks for reporting this. It's surprising, since this issue was fixed in .NET 7 Preview 3. Perhaps it's regressed in some way. However I haven't been able to repro it using Preview 4.

Would you be able to build using the /bl flag (e.g., dotnet build /bl) and then post the generated msbuild.binlog file somewhere I can see it?

marinasundstrom commented 2 years ago

@SteveSandersonMS Here's the file: https://1drv.ms/u/s!AmgzxvYQoUr0naB1l-fywZnSmT13cw?e=bigtO5

I'm on macOS. Silicon.

marinasundstrom commented 2 years ago

It seems to, still, be an issue in macOS on arm64: https://www.strathweb.com/2022/03/running-net-7-apps-on-wasi-on-arm64-mac/

SteveSandersonMS commented 2 years ago

Thanks for reporting this, @marinasundstrom! I tracked it down to the packages on NuGet being a bit out of date.

Please try updating your project to the latest version of Wasi.Sdk and related packages (i.e., 0.1.1 or later, which was just published). This should make the problem disappear for people using .NET 7 Preview 4 and later.

marinasundstrom commented 2 years ago

Thank you, @SteveSandersonMS! The fix is working. Now I can continue to explore.

Keep up the good work.