domaindrivendev / Swashbuckle.AspNetCore

Swagger tools for documenting API's built on ASP.NET Core
MIT License
5.25k stars 1.31k forks source link

dotnet swagger tofile on linux-x64 > The library 'hostpolicy.dll' required to execute the application was not found #2412

Closed TheDevKnight closed 3 months ago

TheDevKnight commented 2 years ago

Hi,

i build my webapi project for win10-x64/linux-x64/osx-x64/osx.11.0-arm64 with

dotnet publish `
--configuration Release `
--runtime {0} `
--self-contained `
--property:PublishReadyToRun=true `
--property:PublishSingleFile=true `
--property:DebugType=None `
{1}\MyService.csproj'

after that i try to generate the swagger file with

dotnet swagger tofile --output C:\DevGit\my-api-spec.json C:\DevGit\MyService\bin\Release\net6.0\win10-x64\MyService.dll %v1% 

The problem is that the tofile call works only in win10-x64

On all other plattforms the result of the call is these message

A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\DevGit\MyService\bin\Release\net6.0\linux-x64\'.
Failed to run as a self-contained app.
  - The application was run as a self-contained app because 'C:\DevGit\MyService\bin\Release\net6.0\linux-x64\MyService.runtimeconfig.json' did not specify a framework.
  - If this should be a framework-dependent app, specify the appropriate framework in 'C:\DevGit\MyService\bin\Release\net6.0\linux-x64\MyService.runtimeconfig.json'.

The missing runtimeconfig.json exists and has this content

{
  "runtimeOptions": {
    "tfm": "net6.0",
    "includedFrameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "6.0.2"
      },
      {
        "name": "Microsoft.AspNetCore.App",
        "version": "6.0.2"
      }
    ],
    "configProperties": {
      "System.GC.Server": true,
      "System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
      "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
    }
  }
}

I also found a file with the name libhostpolicy.so in the target folder.

Is it not possible to call the toFile on a selft contained app other then win10-x64?

Regards Henry

snierste3E commented 1 year ago

Any update on this? Also interested in a solution

agilenut commented 1 year ago

I'd also like to see a solution to this.

github-actions[bot] commented 6 months ago

This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.

martincostello commented 6 months ago

Please provide a minimal reproducible example as a GitHub repository that demonstrates the issue you're experiencing so we can look into this further.

github-actions[bot] commented 4 months ago

This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.

github-actions[bot] commented 3 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.