-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Microsoft.Extensions.ApiDescription.Server : After build, OpenAPI specification file isn't present in the build result #59334
Comments
I think this is by design that it's in obj (I don't know why though). There is an MSBuild property you can set to customise where it's written to: |
Try |
I get the same error with From your example, how is defined |
It's part of using the Artifacts Output feature: https://learn.microsoft.com/dotnet/core/sdk/artifacts-output |
Ok, thank for your help. |
I agree that they should update the docs to correctly list where the file is outputted to. I'm working on a Vue+AspNet template project and here is my property group settings:
A second strange behavior I've found is if you delete this file and rebuild you won't get a new file until you've either changed something about your server code or cleaned your project. I would ideally like to recreate this file if it is missing regardless of the other incremental build optimizations dotnet uses. |
@IsaacCloos Would you be interested in opening a PR on the docs to tweak this? You're correct that the docs are currently incorrect about the default output directory.
Yeah, unfortunately the current strategy is plagued with incrementally issues. :/ This is a good opportunity to dupe this bug report to #58353. The |
Can someone explain where this file is? I feel like the mock server isn't even running since the build takes 4 seconds. <PropertyGroup>
<OpenApiDocumentsDirectory>$(MSBuildProjectDirectory)</OpenApiDocumentsDirectory>
<OpenApiGenerateDocumentsOptions>--file-name openapi-schema</OpenApiGenerateDocumentsOptions>
</PropertyGroup>
...
<PackageReference Include="Microsoft.Extensions.ApiDescription.Server" Version="9.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference> Deleted bin and obj dirs PS C:\Users\maste\Documents\GitHub\stt-api-backend\SttApi> dotnet build
Restore complete (1.5s)
SttApi succeeded (1.5s) → bin\Debug\net9.0\SttApi.dll
Build succeeded in 3.5s
PS C:\Users\maste\Documents\GitHub\stt-api-backend\SttApi> Get-ChildItem openapi-schema.json -Recurse
PS C:\Users\maste\Documents\GitHub\stt-api-backend\SttApi> All json filePS C:\Users\maste\Documents\GitHub\stt-api-backend\SttApi> Get-ChildItem *.json -Recurse
Directory: C:\Users\maste\Documents\GitHub\stt-api-backend\SttApi\Assets
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 2023-07-23 4:12 PM 49630 countries.json
-a--- 2023-09-01 10:03 AM 15539 ExchangeRates.json
-a--- 2023-07-19 11:59 PM 4545 getmakes.json
Directory: C:\Users\maste\Documents\GitHub\stt-api-backend\SttApi\bin\Debug\net9.0\Assets
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 2023-07-23 4:12 PM 49630 countries.json
-a--- 2023-09-01 10:03 AM 15539 ExchangeRates.json
-a--- 2023-07-19 11:59 PM 4545 getmakes.json
Directory: C:\Users\maste\Documents\GitHub\stt-api-backend\SttApi\bin\Debug\net9.0
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 2025-02-20 12:40 AM 833 appsettings.Development.json
-a--- 2025-02-23 4:50 AM 1060 appsettings.json
-a--- 2025-02-20 12:16 AM 1302 appsettings.Production.json
-a--- 2025-02-23 6:33 PM 3 MvcTestingAppManifest.json
-a--- 2025-02-23 6:33 PM 221866 SttApi.deps.json
-a--- 2025-02-23 6:33 PM 416 SttApi.runtimeconfig.json
-a--- 2025-02-23 6:33 PM 14842 SttApi.staticwebassets.endpoints.json
-a--- 2025-02-23 6:33 PM 807 SttApi.staticwebassets.runtime.json
Directory: C:\Users\maste\Documents\GitHub\stt-api-backend\SttApi\obj\Debug\net9.0
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 2025-02-23 6:33 PM 3 MvcTestingAppManifest.json
-a--- 2025-02-23 6:33 PM 14842 staticwebassets.build.endpoints.json
-a--- 2025-02-23 6:33 PM 20361 staticwebassets.build.json
-a--- 2025-02-23 6:33 PM 807 staticwebassets.development.json
-a--- 2025-02-23 6:33 PM 1292 staticwebassets.pack.json
-a--- 2025-02-23 6:33 PM 179 SttApi.sourcelink.json
Directory: C:\Users\maste\Documents\GitHub\stt-api-backend\SttApi\obj
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 2025-02-23 6:33 PM 334724 project.assets.json
-a--- 2025-02-23 6:33 PM 5901 SttApi.csproj.nuget.dgspec.json
Directory: C:\Users\maste\Documents\GitHub\stt-api-backend\SttApi\Properties\ServiceDependencies\SttApiWindowsAppService - Web Deploy
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 2024-03-25 10:14 PM 4381 profile.arm.json
Directory: C:\Users\maste\Documents\GitHub\stt-api-backend\SttApi\Properties
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 2025-02-20 1:03 AM 1306 launchSettings.json
Directory: C:\Users\maste\Documents\GitHub\stt-api-backend\SttApi
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 2025-02-20 12:40 AM 833 appsettings.Development.json
-a--- 2025-02-23 4:50 AM 1060 appsettings.json
-a--- 2025-02-20 12:16 AM 1302 appsettings.Production.json |
Ping @elibroftw So :
Modify MyApi.csproj : <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup>
<OpenApiDocumentsDirectory>$(MSBuildProjectDirectory)</OpenApiDocumentsDirectory>
<OpenApiGenerateDocumentsOptions>--file-name openapi-schema</OpenApiGenerateDocumentsOptions>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.2" />
<PackageReference Include="Microsoft.Extensions.ApiDescription.Server" Version="9.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project> Then :
So it's work fine. Maybe a error in endpoint definition prevents to generate oas. |
Hmm okay yeah I should work backwards. Thanks. |
Is there an existing issue for this?
Describe the bug
I try to follow the documentation 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 :
Then if we display the bin :
The file
MyApi.json
is missing.But the file is correctly generated and present in
obj
:Exceptions (if any)
No response
.NET Version
9.0.101
Anything else?
No response
The text was updated successfully, but these errors were encountered: