我一直在使用 Visual Studio Mac 一段时间,并且刚刚将其更新到发布版本。我还下载并安装了 .NET Core 2.0 Preview 1。从 shell 提示我可以生成一个新的 Web API 项目:
dotnet2 davec$ dotnet --version
2.0.0-preview1-005977
dotnet2 davec$ dotnet new webapi
The template "ASP.NET Core Web API" was created successfully.
This template contains technologies from parties other than Microsoft, see https://aka.ms/template-3pn for details.
Processing post-creation actions...
Running 'dotnet restore' on dotnet2/dotnet2.csproj...
Restore succeeded.
我可以从 shell 构建和运行该项目。但是当我在 Visual Studio for Mac 中打开它时,IDE 尝试并无法恢复:
Errors in dotnet2/dotnet2.csproj
Unable to resolve 'Microsoft.NETCore.App (>= 2.0.0)' for '.NETCoreApp,Version=v2.0'.
Unable to resolve 'Microsoft.NETCore.App (>= 2.0.0)' for '.NETCoreApp,Version=v2.0 (win)'.
Unable to resolve 'Microsoft.NETCore.App (>= 2.0.0)' for '.NETCoreApp,Version=v2.0 (win-x64)'.
Unable to resolve 'Microsoft.NETCore.App (>= 2.0.0)' for '.NETCoreApp,Version=v2.0 (win-x86)'.
NuGet Config files used:
~/.config/NuGet/NuGet.Config
Feeds used:
https://api.nuget.org/v3/index.json
Restore failed for 'Microsoft.NETCore.App (>= 2.0.0)'.
Restore failed.
最佳答案
为了完整起见,在@jmoerdyk 的评论之后记录答案:
我的环境:
MacOSX 10.12.4
dotnet 版本:2.0.0-preview1-005977
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeFrameworkVersion>2.0.0-preview1-002111-00</RuntimeFrameworkVersion>
</PropertyGroup>
</Project>
关于macos - Visual Studio Mac 与 dotnet core 2 不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43927111/