Microsoft.Extensions.ApiDescription.Server : After build, OpenAPI specification file isn't present in the build result
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
I try to follow the documentation [Generate OpenAPI documents at build-time](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/openapi/aspnetcore-openapi?view=aspnetcore-9.0&tabs=net-cli#generate-openapi-documents-at-build-time), but the OpenAPI specification file isn't present in the build result.
I reproduce on Windows 10 and Windows 11 (I haven't tested it elsewhere).
### Expected Behavior
The OpenAPI specification file is in the build result.
### Steps To Reproduce
So the script :
```
dotnet new webapi --name MyApi --no-https --use-program-main --use-controllers
cd MyApi
dotnet add package Microsoft.Extensions.ApiDescription.Server
dotnet build
```
Then if we display the bin :
```
> dir bin\Debug\net9.0
Volume in drive C has no label.
Volume Serial Number is 60F0-FEC7
Directory of C:\t\dotnte-poc\MyApi\bin\Debug\net9.0
05/12/2024 15:50 .
05/12/2024 15:50 ..
05/12/2024 15:50 127 appsettings.Development.json
05/12/2024 15:50 151 appsettings.json
29/10/2024 14:30 192 800 Microsoft.AspNetCore.OpenApi.dll
06/08/2024 10:15 239 024 Microsoft.OpenApi.dll
05/12/2024 15:50 2 235 MyApi.deps.json
05/12/2024 15:50 8 704 MyApi.dll
05/12/2024 15:50 145 408 MyApi.exe
05/12/2024 15:50 21 348 MyApi.pdb
05/12/2024 15:50 416 MyApi.runtimeconfig.json
05/12/2024 15:50 68 MyApi.staticwebassets.endpoints.json
10 File(s) 610 281 bytes
2 Dir(s) 98 535 710 720 bytes free
```
The file `MyApi.json` is missing.
---
But the file is correctly generated and present in `obj` :
```
>dir obj
Volume in drive C has no label.
Volume Serial Number is 60F0-FEC7
Directory of C:\t\dotnte-poc\MyApi\obj
05/12/2024 15:50 .
05/12/2024 15:50 ..
05/12/2024 15:50 Debug
05/12/2024 15:50 2 982 MyApi.csproj.nuget.dgspec.json
05/12/2024 15:50 2 165 MyApi.csproj.nuget.g.props
05/12/2024 15:50 551 MyApi.csproj.nuget.g.targets
05/12/2024 15:50 1 730 MyApi.json <<<<< Here
05/12/2024 15:50 38 MyApi.OpenApiFiles.cache
05/12/2024 15:50 20 520 project.assets.json
05/12/2024 15:50 581 project.nuget.cache
7 File(s) 28 567 bytes
3 Dir(s) 98 537 242 624 bytes free
```
### Exceptions (if any)
_No response_
### .NET Version
9.0.101
### Anything else?
_No response_
Contributor guide
Research direction
Start with the documented build-time OpenAPI steps and the `dotnet new webapi`, package-add, and `dotnet build` reproduction. Compare the generated `obj/MyApi.json` with the `bin/Debug/net9.0` contents, then trace the Microsoft.Extensions.ApiDescription.Server build integration; done means the specification file is present in the build result as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100