How to force Swashbuckle.Aspnetcore.Cli to use netcoreapp3.1?

Viewed 4242

I'm upgrading a project to use .Net Core 3.1 from 2.2, and am struggling with getting my tools working.

I have this section in my .csproj file which generates a swagger.json file at publish time - it gets executed in our build pipeline and published as an artifact.

<ItemGroup>
  <DotNetCliToolReference Include="Swashbuckle.AspNetCore.Cli" Version="5.2.1" />
</ItemGroup>
<Target Name="Swagger" AfterTargets="PrepareForPublish" DependsOnTargets="Build" Outputs="$(PublishDir)swagger.json">
  <Exec Command="dotnet swagger tofile --output $(PublishDir)swagger.json $(OutputPath)\$(AssemblyName).dll v1" />
</Target>

But I'm getting these errors:

Package Swashbuckle.AspNetCore.Cli 5.2.1 is not compatible with netcoreapp2.2 (.NETCoreApp,Version=v2.2). Package Swashbuckle.AspNetCore.Cli 5.2.1 supports:
- netcoreapp2.1 (.NETCoreApp,Version=v2.1) / any
- netcoreapp3.0 (.NETCoreApp,Version=v3.0) / any

and:

Invalid project-package combination for Swashbuckle.AspNetCore.Cli 5.2.1. DotnetToolReference project style can only contain references of the DotnetTool type

The weird thing is that my project is using 3.1 - I did a ctrl+f on both "netcoreapp2.2" and "2.2" and couldn't find anywhere that was being specified. How can I force my CLI tool to use the correct .NET Core version?

2 Answers
Related