Referencing Swashbuckle.AspNetCore 5.0.0 in library with multiple targets
See original GitHub issueVERSION:
5.0.0
STEPS TO REPRODUCE:
Create project with multiple targets, e.g.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
<PackageId>Test</PackageId>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.0.0" />
</ItemGroup>
</Project>
EXPECTED RESULT:
Project should compile
ACTUAL RESULT:
Compilation error: The target “GenerateOpenApiDocuments” does not exist in the project.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
Getting a build err when I do "dotnet run"
I am having problems Swashbuckle.AspNetCore version 5.0.0-rc2 as explained in this post "https://github.com/domaindrivendev/Swashbuckle.
Read more >What's new in ASP.NET Core 5.0
Swashbuckle is a popular open-source NuGet package that emits OpenAPI documents dynamically. Swashbuckle does this by introspecting over the API ...
Read more >Enriched Web API Documentation using Swagger/OpenAPI in ...
In this article, we will learn about Web API documentation , how we can automatically generate it in ASP .NET Core and how...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve narrowed this down to the referenced package in Swashbuckle 5.x: https://github.com/dotnet/aspnetcore/tree/master/src/Tools/Extensions.ApiDescription.Server
Options listed here: https://github.com/dotnet/aspnetcore/blob/master/src/Tools/Extensions.ApiDescription.Server/src/build/Microsoft.Extensions.ApiDescription.Server.props
Just add this to your csproj file and it will disable trying to generate your swagger file:
Or you can disabled it on build events only:
I’ve run into this same issue. Interestingly enough, if I specify the target framework on the build command line like
dotnet build <project> --framework netcoreapp3.1
for each target framework, the build succeeds. When it tries to build all target frameworks at once, it fails. However, that solution doesn’t work when building as part of thedotnet pack
command.