RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.82k stars 1.3k forks source link

Database Exception: Microsoft.Data.SqlClient is not supported on this platform. #4346

Open mahomedalid opened 1 year ago

mahomedalid commented 1 year ago

I got an error when executing nswag:

$ npx nswag aspnetcore2openapi /assembly:./IST.dll
NSwag NPM CLI
NSwag command line tool for .NET Core Net70, toolchain v13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v13.0.0.0))
Visit http://NSwag.org for more information.
NSwag bin directory: /home/mapach/.npm/_npx/58e08e1c8752b753/node_modules/nswag/bin/binaries/Net70
Database Exception: Microsoft.Data.SqlClient is not supported on this platform.

My dependencies include Microsoft.Data.SqlClient Version="5.1.0" This is a net7.0 API.

NSwag version: 13.18.2.0 NJsonSchema version: 10.8.0.0 (Newtonsoft.Json v13.0.0.0)

dougclutter commented 1 year ago

Did you ever work around this? I'm getting the same thing on Windows when running via MSBuild like this:

    <Target Name="CreateSwagger" AfterTargets="PostBuildEvent">
        <Message Importance="high" Text="Generating api.json from code" />
        <Exec WorkingDirectory="$(ProjectDir)" Command="$(NSwagExe_Net70) aspnetcore2swagger /assembly:$(TargetDir)SOM.WDADPR.Web.dll /output:$(ProjectDir)api.json /variables:Configuration=$(Configuration)" EnvironmentVariables="ASPNETCORE_ENVIRONMENT=Development" />
    </Target>