dotnet 6 更新后,dotnet run 无法正常工作。

5

我昨天从.Net 5更新到.Net 6,现在我的项目无法使用dotnet run启动。然后我收到以下错误信息:

Building...
warn: Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer[5]
      The ASP.NET Core developer certificate is in an invalid state. To fix this issue, run the following commands 'dotnet dev-certs https --clean' and 'dotnet dev-certs https' to remove all existing ASP.NET Core development certificates and create a new untrusted developer certificate. On macOS or Windows, use 'dotnet dev-certs https --trust' to trust the new certificate.
fail: Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer[4]
      The ASP.NET Core developer certificate is in an invalid state. To fix this issue, run the following commands 'dotnet dev-certs https --clean' and 'dotnet dev-certs https' to remove all existing ASP.NET Core development certificates and create a new untrusted developer certificate. On macOS or Windows, use 'dotnet dev-certs https --trust' to trust the new certificate.

我尝试了所有的步骤来删除/清除并重新创建,但是这并没有帮助。服务器已经启动,但无法从浏览器建立连接。 我使用的是Mac OS 11。 有人有想法吗?
3个回答

9

我曾经遇到过类似的问题,在编译和再次运行之前,使用dotnet clean清除项目后问题得到了解决。


5
在项目文件的<PropertyGroup>元素下添加<UseAppHost>false</UseAppHost>。 要了解更多关于这个(希望是临时性的)问题,请查看这里

第三方编辑

引用该链接:

为解决此问题,可以在项目文件中设置MSBuild属性为false,例如:

<PropertyGroup>
    <UseAppHost>false</UseAppHost>
</PropertyGroup>

您也可以将此属性作为dotnet run命令的一部分传递: dotnet run -p:UseAppHost=false

1
非常感谢,这解决了我相同的问题。有趣的是,在过去的几周里它一直有效(我只在一个月前开始进行C#开发),但在今天更新Visual Studio到最新预览版后就出现了问题...不知道为什么。 - aurora

0

我不得不删除所有3.1.4xx以上的SDK,因为我正在使用3.1.x版本。只有在这之后,新生成的开发证书才能正常工作。

当我开始使用更新的dotnet core版本时,我会安装SDK。

MacOS位置 = /usr/local/share/dotnet/sdk

MacOS版本12.3 Monterey


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接