Can a Minimal API project include the Microsoft.AspNetCore.App framework?

Falanga, Rod, DOH 400 Reputation points
2025-10-20T20:51:20.56+00:00

I've been getting this error for a couple days:

There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'browser-wasm'.

I've been trying to figure out where Microsoft.AspNetCore.App is coming into the project (the Visual Studio solution has 4 VS projects in it). The project I'll call FP.Client is the one that raises that error. But it doesn't include Microsoft.AspNetCore.App. However, it does include a Minimal API project which I'll call FP.DataActionsAPI. FP.DataActionsAPI has references to Microsoft.AspNetCore.App and Microsoft.NETCore.App. Doing a quick search to see if Minimal API projects should or can include Microsoft.AspNetCore.App, I don't get any answers. I suspect that Minimal API projects shouldn't include Microsoft.AspNetCore.App, but I want to double check that. My guess is that Minimal APIs can be used by either server-side Blazor or client-side Blazor apps, if the Minimal API project doesn't include Microsoft.AspNetCore.App, but if the Minimal API project does include Microsoft.AspNetCore.App, then it can only be used by server-side Blazor projects. Am I correct?

Developer technologies | ASP.NET | ASP.NET API
0 comments No comments
{count} votes

Answer recommended by moderator
  1. Danny Nguyen (WICLOUD CORPORATION) 3,500 Reputation points Microsoft External Staff
    2025-10-21T06:03:01.1833333+00:00

    Hi @Falanga, Rod, DOH ,

    The error you’re seeing stems not from the fact that you’re using a Minimal API, but from a mismatch between server-side shared frameworks and a client-side (WebAssembly) runtime.

    The Microsoft.AspNetCore.App package is a shared framework bundle that contains assemblies for ASP.NET Core and is installed with the runtime. Projects that target the Microsoft.NET.Sdk.Web SDK implicitly reference it, so you don’t need to (and should not) add it manually. You can read more on it here Microsoft.AspNetCore.App metapackage for ASP.NET Core | Microsoft Learn

    When you build a WebAssembly app (i.e. targeting browser-wasm), the runtime environment is the browser’s WebAssembly-CLR, which obviously cannot load the server’s shared framework runtime pack. That’s why you got "There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'browser-wasm'"

    In short: you have a client-side build trying to pull in a server-side shared framework.

    Make sure your Minimal API project (server) uses the Microsoft.NET.Sdk.Web SDK, targets a server runtime (e.g., net8.0/net9.0), and does not explicitly reference Microsoft.AspNetCore.App. On the client (Blazor WebAssembly) side, make sure that you do not reference the API project directly in a way that brings in that shared framework - consume the API via HTTP instead.

    Hope this helps.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 81,191 Reputation points Volunteer Moderator
    2025-10-20T21:56:50.47+00:00

    Minimal API projects are part of asp.net core webapi website and are an alternative to creating MVC controllers. typically you would use the .Web sdk. the project should be producing a console app that hosts a webapi site. as you are implementing a web server, they are server side only.

    sample webapi with Minimal API project with only the openapi nuget package added.

    <Project Sdk="Microsoft.NET.Sdk.Web">
    
      <PropertyGroup>
        <TargetFramework>net9.0</TargetFramework>
        <Nullable>enable</Nullable>
        <ImplicitUsings>enable</ImplicitUsings>
      </PropertyGroup>
    
      <ItemGroup>
        <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.3" />
        <PackageReference Include="Microsoft.Extensions.ApiDescription.Server" Version="9.0.4">
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
          <PrivateAssets>all</PrivateAssets>
        </PackageReference>
      </ItemGroup>
    
    </Project>
    
    var builder = WebApplication.CreateBuilder(args);
    
    builder.Services.AddOpenApi();
    
    var app = builder.Build();
    
    // Configure the HTTP request pipeline.
    if (app.Environment.IsDevelopment())
    {
        app.MapOpenApi();
        app.MapGet("/", () => Results.Redirect("openapi/v1.json"));
    }
    
    app.UseHttpsRedirection();
    
    var summaries = new[]
    {
        "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
    };
    
    app.MapGet("/weatherforecast", () =>
    {
        var forecast =  Enumerable.Range(1, 5).Select(index =>
            new WeatherForecast
            (
                DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
                Random.Shared.Next(-20, 55),
                summaries[Random.Shared.Next(summaries.Length)]
            ))
            .ToArray();
        return forecast;
    })
    .WithName("GetWeatherForecast");
    
    app.Run();
    
    record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
    {
        public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
    }
    

    note: if you call from Blazor WASM you will need to implement CORS. If the Blazor app is auto, you can use the hosting server project as a proxy to the minimal webapi project. see the yarp:

    https://github.com/dotnet/yarp

    1 person found this answer helpful.
    0 comments No comments

  2. Drake Bourque 0 Reputation points
    2025-10-21T01:18:21.9566667+00:00

    var builder = WebApplication.CreateBuilder(args);

    builder.Services.AddOpenApi();

    var app = builder.Build();

    // Configure the HTTP request pipeline.

    if (app.Environment.IsDevelopment())

    {

    app.MapOpenApi();
    
    app.MapGet("/", () => Results.Redirect("openapi/v1.json"));
    

    }

    app.UseHttpsRedirection();

    var summaries = new[]

    {

    "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
    

    };

    app.MapGet("/weatherforecast", () =>

    {

    var forecast =  Enumerable.Range(1, 5).Select(index =>
    
        new WeatherForecast
    
        (
    
            DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
    
            Random.Shared.Next(-20, 55),
    
            summaries[Random.Shared.Next(summaries.Length)]
    
        ))
    
        .ToArray();
    
    return forecast;
    

    })

    .WithName("GetWeatherForecast");

    app.Run();

    record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)

    {

    public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
    

    }

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.