我已经使用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.
答案 0 :(得分:3)
为了完整起见,请在@ 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>
&#13;
答案 1 :(得分:3)
Visual Studio for Mac 7.1与.NET Core 2.0 Preview 2兼容,但目前处于测试阶段。从主菜单中选择“检查更新”,然后切换到“Beta”频道。请参阅Xamarin docs和preview release notes。
答案 2 :(得分:0)
现在您可以从here获取.NET Core 2.0,然后安装pkg。下一步是改变解决方案中的目标框架,以及玩得开心!