gpt4 book ai didi

macos - Visual Studio Mac 与 dotnet core 2 不兼容

转载 作者:行者123 更新时间:2023-12-04 12:04:33 25 4
gpt4 key购买 nike

我一直在使用 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

  • 在文本编辑器(vi、TextEdit、VS Code)中打开 csproj 文件
  • 修改 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>


  • 运行 nuget restore,构建项目,你应该很高兴
  • 关于macos - Visual Studio Mac 与 dotnet core 2 不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43927111/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com