1

Hello wondering if anyone has any ideas as to why running dotnet swagger doesn't work on Apple Silicon compared to installing Swashbuckle.AspNetCore.Cli globally via dotnet tool install.

For context I have a .NET 6 API with a PostBuild target in my .csproj file to generate a swagger.json on build which looks like what is show below

<Target Name="SwaggerToFile" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU' AND '$(NCrunch)' != '1'" AfterTargets="AfterBuild">
    <Exec Command="dotnet tool restore" />
    <Exec Command="dotnet swagger tofile --output doc.json $(OutputPath)$(AssemblyName).dll" />
</Target>

On Apple Silicon this step fails and you get the following error message

 It was not possible to find any compatible framework version
         The framework 'Microsoft.AspNetCore.App', version '5.0.0' (arm64) was not found.
           - The following frameworks were found:
               6.0.5 at [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
         
         You can resolve the problem by installing the specified framework and/or SDK.

^ The above doesn't exist as far as I'm aware

However if I install the Swashbuckle.AspNetCore.Cli globally and then change the command to swagger tofile --output doc.json $(OutputPath)$(AssemblyName).dll it works. Trying to understand why there is a difference here if it's the same CLI tool under the hood.

I only have .NET 6.0 SDKs and Runtimes and am doing nothing fancy with Rosetta.

min1137
  • 11
  • 1

1 Answers1

1

I'm using an M2 Macbook Pro and I needed to add the ff to my .zshrc to make swagger CLI work.

~/.zshrc

export PATH="$HOME/.dotnet/tools:$PATH"

I can't recall the specifics but it had something to do with the path that is being added to the environment variables. In this case, the dotnet tool path should be $HOME/.dotnet/tools.

After this change, I am able to use the swagger command by swagger tofile ...

jegtugado
  • 5,081
  • 1
  • 12
  • 35
  • On second thought I don't think we experienced the same issue. This [link](https://stackoverflow.com/a/66578692/6138713) might be able to help you. Your installed runtime seems to be `6.0.5` while the project is referencing `5.0.0`. Either update the project's target version or install the arm64 for `5.0.0` – jegtugado Sep 26 '22 at 06:33