仅使用最新单声道的Mac上的错误:错误netsdk1045:当前.NET SDK不支持目标.NET CORE 3.1
我正在运行由Cake和Msbuild在各种平台(Windows,Linux,Mac)的目标.NET Core 3.1上构建的相同项目。一切顺利除了在Mac上得到NetSDK1045错误,如下所示:
Project "MyProject.csproj" on node 1 (Build target(s)).
/usr/local/share/dotnet/sdk/3.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(127,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.1. Either target .NET Core 3.0 or lower, or use a version of the .NET SDK that supports .NET Core 3.1.
在MAC上存在问题,我使用的是最新版本的Mono 6.12.0.122,其中包括MSBUILD 16.6.0。
.NET CORE 3.1已安装。我没有任何覆盖或global.json。这是所有已安装的SDK的列表:
dotnet --list-sdks
2.1.802 [/usr/local/share/dotnet/sdk]
2.2.402 [/usr/local/share/dotnet/sdk]
3.0.100 [/usr/local/share/dotnet/sdk]
3.1.416 [/usr/local/share/dotnet/sdk]
3.1.417 [/usr/local/share/dotnet/sdk]
5.0.406 [/usr/local/share/dotnet/sdk]
6.0.201 [/usr/local/share/dotnet/sdk]
以下是dotnet
命令的有关运行时环境的信息:
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.14
OS Platform: Darwin
RID: osx.10.14-x64
Base Path: /usr/local/share/dotnet/sdk/6.0.201/
为什么错误的NETSDK1045发生了,尽管.NET CORE 3.1甚至安装了以后的版本?为什么仅在Mac上发生?
I am running the same project built by Cake and MSBuild on various platforms (Windows, Linux, Mac) targeting .NET Core 3.1. Everything goes well except on Mac where I'm getting NETSDK1045 error as follows:
Project "MyProject.csproj" on node 1 (Build target(s)).
/usr/local/share/dotnet/sdk/3.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(127,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.1. Either target .NET Core 3.0 or lower, or use a version of the .NET SDK that supports .NET Core 3.1.
On Mac, where the problem exists, I'm using latest version of Mono 6.12.0.122 which includes MSBuild 16.6.0.
.NET Core 3.1 is installed. I don't have any override or global.json. Here is the list of all installed SDKs:
dotnet --list-sdks
2.1.802 [/usr/local/share/dotnet/sdk]
2.2.402 [/usr/local/share/dotnet/sdk]
3.0.100 [/usr/local/share/dotnet/sdk]
3.1.416 [/usr/local/share/dotnet/sdk]
3.1.417 [/usr/local/share/dotnet/sdk]
5.0.406 [/usr/local/share/dotnet/sdk]
6.0.201 [/usr/local/share/dotnet/sdk]
Here is the information about the runtime environment from the dotnet
command:
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.14
OS Platform: Darwin
RID: osx.10.14-x64
Base Path: /usr/local/share/dotnet/sdk/6.0.201/
Why does the error NETSDK1045 happens in spite of .NET Core 3.1 and even later versions are installed? And why does it happen on Mac only?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个常见的问题,即MSBuild的旧版本没有看到.NET Core SDK的新版本。
在Mac上,问题是在MSBUILD 16.6.0中,它以最新稳定版本的单声道(6.12.0.122)发货。
此版本的MSBuild比.NET Core 3.1.416 SDK发布。因此,MSBuild找不到.NET Core的版本,但是正在寻找发布时MSBuild支持的较旧版本。它找到了.NET Core 3.0,这对3.1项目不起作用,因此这是错误的原因。矛盾的是,如果安装了SDK的较早版本,则安装了3.1.416,则MSBuild能够找到它。因此,有两种解决方案:(1)卸载所有SDK版本早于3.1.416或(2)更新MSBUILD。
我安装了Mono的“预览” 6.12.0.174版本,该版本带有更新的MSBUILD -16.10.1,因此即使安装了早期版本,该版本也能够成功找到.NET Core 3.1.416 SDK。因此,溶液NR。 2(从上述的情况下)在我的情况下起作用。
MAC的Microsoft Visual Studio中也存在同样的问题,但最近由Microsoft修复。问题与蛋糕制造无关。
在Windows上,可能会出现MS Build fusisual Studio 2017的错误,但没有看到.NET Core 3.1 SDK。如果您采用较新的MS Build,即使用Visual Studio 2019发货的MS构建,则问题将得到解决。
There is a common problem that and old version of MSBuild does not see the new version of .NET Core SDK.
On Mac, the problem is in MSBuild 16.6.0, which is shipped with the latest stable version of Mono (6.12.0.122).
This version of MSBuild was released earlier than the .NET Core 3.1.416 SDK. Therefore, MSBuild cannot find that version of .NET Core, but was looking for an older version that was supported by MSBuild at the time of its release. It finds .NET Core 3.0, which would not work for 3.1 projects, so that's the cause of the error. Paradoxically, if no earlier version of SDK than 3.1.416 is installed, then MSBuild was able to find it. So, there are two solutions: (1) uninstall all SDK versions earlier than 3.1.416, or (2) update MSBuild.
I installed Mono's "Preview" version 6.12.0.174, which came with the updated MSBuild - 16.10.1, so that version was able to successfully find the .NET Core 3.1.416 SDK, even though earlier versions were installed. Therefore, solution nr. 2 (from those described above) worked in my case.
The same problem existed in Microsoft Visual Studio for Mac but was fixed by Microsoft recently. The issue is not related to Cake Build.
On Windows, there may be an error that MS Build shipped with Visual Studio 2017 does not see .NET Core 3.1 SDK. If you take a newer MS Build, i.e., the one that is shipped with Visual Studio 2019, the problem will be resolved.