SteveSandersonMS / dotnet-wasi-sdk

Packages for building .NET projects as standalone WASI-compliant modules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

marinasundstrom opened this issue · comments

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>

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?

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.

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

Keep up the good work.