无法将 ASP.NET Web API 发布到 Azure 应用服务(使用 SwashBuckle)
我有一个应用服务已经在 Azure 中运行了一段时间。我刚刚将其更新到.NET 6.0(并在本地安装了 Swashbuckle.aspnetcore.cli v6.2.3)。
我无法发布到 Azure。当我第一次尝试时,它告诉我找不到 aspnetcore3.0,它能找到的唯一已安装版本是 .NET 5.1.4 和 .NET 6.0.1。
请遵循此处的说明: https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1485
我向我的项目添加了一个 global.json:
{
"sdk":
{
"version": "6.0.1",
"rollForward": "latestPatch"
}
}
现在,当我尝试发布时,出现以下错误:
Failed to install DotNet CLI tool 'swashbuckle.aspnetcore.cli'. Error dotnet tool restore
Could not execute because the application was not found or a compatible .NET SDK is not installed.
Possible reasons for this include:
* You intended to execute a .NET program:
The application 'tool' does not exist.
* You intended to execute a .NET SDK command:
A compatible installed .NET SDK for global.json version [6.0.1] from [C:\Projects\MyProject\global.json] was not found.
Install the [6.0.1] .NET SDK or update [C:\Projects\MyProject\global.json] with an installed .NET SDK:
如何发布我的应用程序服务?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以尝试的简单解决方法之一是 -
另外,请尝试参考此链接。
One of the simple workaround that you can try is -
Also, please try referring this link.
对于发现此问题的其他人,我最终通过编辑项目根文件夹中“.config”文件夹中的文件“dotnet-tools.json”并更改 swashbuckle.aspnetcore.api 的版本从 5.6.3 解决了该问题至 6.3.0。
我还更新到了 swashbuckle 6.3.0,并将 global.json 更改为:
请注意使用latestMajor 而不是latestPatch。
To anyone else that finds this issue, I finally fixed it by editing the file "dotnet-tools.json" in the ".config" folder in the project root folder, and changing the version of swashbuckle.aspnetcore.api from 5.6.3 to 6.3.0.
I also updated to swashbuckle 6.3.0, and changed global.json to be:
Note the use of latestMajor rather than latestPatch.
就我而言,Swashbuckle.Core 库导致了此问题,我从 NuGet 安装该库来尝试一些东西。当我导航到“依赖项”->包,我看到一个错误,指出该包的兼容性适用于 .NET Framework 版本:v4.6、v4.7、v4.8,而不适用于目标框架 net6.0。
因此,卸载这个 NuGet 包让我继续运行!顺便说一句,当我尝试将 WebApi 发布到 Azure 应用服务时,发生了错误(只是为了设置一些上下文)。
In my case, the
Swashbuckle.Core
library was causing this issue which I installed from NuGet to try something out. When I navigated to Dependencies -> Packages, I saw an error which stated that this package's compatibility is for that of .NET Framework versions: v4.6, v4.7, v4.8 and NOT for the target framework net6.0.Therefore, uninstalling this NuGet package got me running! BTW, the error occurred (just to set some context), when I attempted to publish my WebApi to Azure App Service.
就我而言,我最初错过了安装所有三个必需的 Swagger 包。安装它们后,我的问题得到了解决。
In my case, I initially missed installing all three required Swagger packages. After installing them, my issue was resolved.