.net-coreasp.net-core-webapiopenapi

ApiDescription.Server errors during build


I have a .NET 8 web project that contains API controllers. I want to generate the Swagger OpenApi.json document during the build so I installed Microsoft.Extensions.ApiDescription.Server v9.0.2.

Following this document (https://learn.microsoft.com/en-us/aspnet/core/fundamentals/openapi/overview?view=aspnetcore-9.0&preserve-view=true), I updated the .csproj file with the <PropertyGroup> entry. The build is generating the following error:

The application to execute does not exist:
'C:\Users\cr\.nuget\packages\microsoft.extensions.apidescription.server\9.0.2\tools\net8.0\GetDocument.Insider.dll'

Based on one discussion I found on Github. I also installed Microsoft.OpenApi v1.6.2.3 and Microsoft.AspNetCore.OpenApi v8.0.12 which didn't help.

There's just not a lot of documentation on this error. Thanks for any assistance.


Solution

  • You should use 8.0.13 version in .net 8, like below.

    <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.13" />
    <PackageReference Include="Microsoft.Extensions.ApiDescription.Server" Version="8.0.13">
    </PackageReference>
    

    We should make sure all the packages are all 8.x.x version first, if it still not works, we can follow below suugestions.

    1. Please navigate to the path C:\Users\cr\.nuget\packages, and find the4 related packages, and delete it, then try again.

    2. Install .NET 9 SDK, no need to upgrade your .net8 webapplication.