Skip to content

Microsoft.Extensions.ApiDescription.Server - Altering Endpoint defined in another project does not re-build document #62274

Open
@MattParkerDev

Description

@MattParkerDev

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

ASP.NET Core - when a minimal endpoint is registered in another project/assembly, the Microsoft.Extensions.ApiDescription.Server document generation does not run in some cases.

builder.MapGet("MyEndpoint1", () => "Hello, World!").WithName("MyEndpoint");

It will run if e.g. it is changed from .MapGet to .MapPost

It will not run if the endpoint path is changed from MyEndpoint1 to MyEndpoint2.

Interestingly, it will run if the endpoint path changes, if the endpoint is defined in the ASP.NET Core project containing the Microsoft.Extensions.ApiDescription.Server reference.

Expected Behavior

OpenApi document generation runs whenever the registered endpoints have changed, in referenced projects.

I understand that this may be hard to fix, as the precise details of the mapped endpoints cannot be determined before building, and may be harder to determine across assemblies. Happy for this to be closed if nothing can be improved :)

Steps To Reproduce

Repro: https://github.com/MattParkerDev/Repro.AspnetCoreOpenApiDocBuild
Using .NET 10 preview 4

  1. Build sln once
  2. Observe WebApi.json - endpoint path is MyEndpoint1
  3. Update the path in ClassLibContainingEndpoint.Endpoints
  4. Observe the path has not changed in WebApi.json, and that the document generation did not run (dotnet build -tlp:v=d or dotnet build --tl:off to see tool invocation in logs)
  5. Update the endpoint path in Program.cs
  6. Observe that the document is generated

Exceptions (if any)

No response

.NET Version

10.0.100-preview.4.25258.110

Anything else?

No response

Activity

added
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
on Jun 7, 2025
added
area-commandlinetoolsIncludes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI
and removed
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
on Jun 7, 2025
MattParkerDev

MattParkerDev commented on Jun 7, 2025

@MattParkerDev
Author

Further investigation points to Microsoft.Extensions.ApiDescription.Server.targets

<Target Name="GenerateOpenApiDocuments" Inputs="$(TargetPath)" Outputs="$(_OpenApiDocumentsCache)">

Running dotnet msbuild /v:detailed /t:GenerateOpenApiDocuments --tl:off:

1>Project "C:\Users\Matthew\Documents\Git\Misc\Repro.AspnetCoreOpenApiDocBuild\src\WebApi\WebApi.csproj" on node 1 (GenerateOpenApiDocuments target(s)).
     1>Target "GenerateOpenApiDocuments" in file "C:\Users\Matthew\.nuget\packages\microsoft.extensions.apidescription.server\10.0.0-preview.4.25258.110\build\Microsoft.Extensions.ApiDescrip
       tion.Server.targets" from project "C:\Users\Matthew\Documents\Git\Misc\Repro.AspnetCoreOpenApiDocBuild\src\WebApi\WebApi.csproj" (entry point):
     1>Skipping target "GenerateOpenApiDocuments" because all output files are up-to-date with respect to the input files.
       Input files: C:\Users\Matthew\Documents\Git\Misc\Repro.AspnetCoreOpenApiDocBuild\artifacts\bin\WebApi\debug\WebApi.dll
       Output files: C:\Users\Matthew\Documents\Git\Misc\Repro.AspnetCoreOpenApiDocBuild\artifacts\obj\WebApi\WebApi.OpenApiFiles.cache

The GenerateOpenApiDocuments target is being skipped, as the WebApi assembly has not changed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-commandlinetoolsIncludes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPIfeature-openapi

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @martincostello@MattParkerDev

        Issue actions

          Microsoft.Extensions.ApiDescription.Server - Altering Endpoint defined in another project does not re-build document · Issue #62274 · dotnet/aspnetcore