-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
Priority:2Work that is important, but not critical for the releaseWork that is important, but not critical for the releasearea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-minimal-hosting
Milestone
Description
Describe the bug
While this isn't yet a fully supported scenario it was possible to build simple ASP.NET Core applications before with NativeAOT. This should in theory still be possible since the WebApplicationBuilder is a thin layer over the existing APIs. That's broken now because we're using Assembly.GetCallingAssembly to get the default application name.
To Reproduce
csproj:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="6.0.0-*" />
</ItemGroup>
</Project>Program.cs
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/", context => context.Response.WriteAsync("Hello World!"));
app.Run();- Run
dotnet publish -r win-x64(I was on windows) - Run the resulting published exe.
Exceptions (if any)
WebApplication1\bin\Debug\net6.0\win-x64\publish\WebApplication1.exe
Unhandled Exception: System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.Reflection.Assembly.GetCallingAssembly() + 0x7a
at Microsoft.AspNetCore.Builder.WebApplication.CreateBuilder(String[]) + 0x1d
at <Program>$.<Main>$(String[]) + 0x3e
at WebApplication1!<BaseAddress>+0x1080f37
at WebApplication1!<BaseAddress>+0x1080fc5
Metadata
Metadata
Assignees
Labels
Priority:2Work that is important, but not critical for the releaseWork that is important, but not critical for the releasearea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-minimal-hosting