英文:
C# Dev Kit (VS Code) on macOS: "Compatible .NET SDK was not found"
问题
我尝试使用 Visual Studio Code 的 C# 开发工具包扩展进行项目开发。
我创建了两个 ASP.NET Core Web API
项目。
它们都能成功构建。
然而,当加载我的工作区时,解决方案资源管理器 对每个项目会显示错误:未找到兼容的 .NET SDK。
查看输出窗口,似乎找到了 SDK,我也能成功构建这两个项目。
看起来只是解决方案资源管理器出了问题。
我也尝试过添加不同的项目类型(类库、控制台应用程序),但它们都会显示相同的错误。
有人知道问题出在哪吗?
英文:
I'm trying to use the C# Dev Kit extension for Visual Studio Code for my project.
I've created two ASP.NET Core Web API
projects.
They can both be built successfully.
However, when my workspace is loaded, the Solution Explorer will give an error for each project: A compatible .NET SDK was not found.
Looking at the output window, it looks like it found the SDK and I'm also able to built both projects just fine.
It looks like it's just an issue with the Solution Explorer.
I've also tried to add different project types (Class Library, Console App) but they all give the same error.
Anyone know what the problem is here?
Here is a screenshot of what I'm looking at:
答案1
得分: 0
这似乎是这个错误:[BUG] 打开工作区时出现“未找到兼容的.NET SDK”。维护者们评论如下:
> 此问题已在 dotnet/msbuild#9038 范围内解决。
>
> 您可以使用修复程序包 https://www.nuget.org/packages/Microsoft.Build.Locator/1.6.1。
> Build.Locator 中存在问题,导致在各种安装环境下破坏了 macOS 上的 SDK 解析器,包括使用 brew,甚至在具有较旧 macOS 的 X64 Mac 机器上没有使用 brew。这已在包中修复,并且 C# Dev Kit 扩展的新更新将携带它(它将在下一个预发布版中,因为我们需要一些时间来测试)。
较旧的回答
在预发布版本 v0.2.70 中已发布了修复程序。尝试使用它,看看是否解决了您的问题(来源)。另请参阅:https://github.com/dotnet/msbuild/issues/9038,其修复程序位于 Microsoft.Build.Locator/1.5.6 中。
如果修复不起作用,并且您使用的是 macOS,请注意,一些 macOS 用户表示卸载 HomeBrew 版本的 dotnet 并使用 pkg 文件进行安装解决了他们的问题(来源)。另一位用户在此处找到了一个涉及将 dylib 复制到搜索文件夹的解决方法。
英文:
This seems to be this bug: [BUG] "A compatible .NET SDK was not found" when opening workspace #120. The maintainers commented:
> The issue was addressed in the scope of dotnet/msbuild#9038
>
> You can use the package with the fix https://www.nuget.org/packages/Microsoft.Build.Locator/1.6.1.
> There are problems in the Build.Locator which broke SDK resolver in Mac under various installations, including using brew, or even without it on X64 Mac machine with older Mac OS. It has been fixed in the package, and a new update of the C# Dev Kit extension will carry it (it will be in the next pre-release, as we need give some short time to be tested).
Older answer
A fix has been released for that issue in pre-release v0.2.70. Try that out and see if that fixes your issue (source). Also related: https://github.com/dotnet/msbuild/issues/9038, the fix for which is in Microsoft.Build.Locator/1.5.6.
If the fix doesn't work for you and you're on macOS, some macOS users have said that uninstalling the HomeBrew version of dotnet and installing using the pkg file resolved their issue (source). Another user found a workaround here involving copying a dylib to a searched folder.
答案2
得分: 0
这只是在 Mac OS 上的一个问题。
我之前正在使用 Homebrew 安装 .NET Core SDK。
由于某些问题,VS Code 扩展无法正确定位 SDK。
在使用 Microsoft 的 .pkg
包重新安装 SDK 后,问题得以解决。
英文:
This is only an issue on Mac OS.
I was using Homebrew to install the .NET Core SDK.
Due to some issue, the VS Code extension was therefore not able to properly locate the SDK.
After uninstalling the SDK using Homebrew, I re-installed it using the .pkg
package from Microsoft and that worked.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论