Visual Studio Mac与dotnet core 2不兼容

Dav*_*rke 7 macos .net-core asp.net-core-2.0 visual-studio-mac

我已经使用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.
Run Code Online (Sandbox Code Playgroud)

我可以从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.
Run Code Online (Sandbox Code Playgroud)

Sud*_*hra 3

为了完整起见,在 @jmoerdyk 的评论之后记录答案:

我的环境:MacOSX 10.12.4 dotnet 版本:2.0.0-preview1-005977

  1. 在文本编辑器(vi、TextEdit、VS Code)中打开 csproj 文件
  2. 将 Target Framework 和 RuntimeFrameworkVersion 修改为:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <RuntimeFrameworkVersion>2.0.0-preview1-002111-00</RuntimeFrameworkVersion>
  </PropertyGroup>

</Project>
Run Code Online (Sandbox Code Playgroud)

  1. 运行 nuget Restore,构建项目,然后就可以开始了