本文介绍了当前的 .NET SDK 不支持面向 .NET Core 2.2.(SDK 2.2.202)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

许多类似问题中的另一个问题,但搜索到的解决方案都没有帮助(请参阅下面查看的问题).

在撰写本文时,.NET Core v2.2 尚未预览,最新版本为 v2.2.202(发布日期,2019 年 2 月 4 日).

我通过安装其他框架"安装了那个,我安装了 x64,我之前安装的所有其他版本也是那个版本.

安装后,当我创建一个新项目时,它显示:

但是当我打开属性时,它没有:

dotnet --info 在项目目录下,给出如下结果:

.NET Core SDK(反映任何 global.json):版本:2.2.202提交:8a7ff6789d运行环境:操作系统名称:Windows操作系统版本:10.0.17134操作系统平台:WindowsRID:win10-x64基本路径:C:Program Filesdotnetsdk2.2.202主机(用于支持):版本:2.2.3提交:6b8ad509b6已安装的 .NET Core SDK:2.1.2 [C:Program Filesdotnetsdk]2.1.4 [C:Program Filesdotnetsdk]2.1.201 [C:Program Filesdotnetsdk]2.1.202 [C:Program Filesdotnetsdk]2.1.401 [C:Program Filesdotnetsdk]2.1.505 [C:Program Filesdotnetsdk]2.2.202 [C:Program Filesdotnetsdk]安装的 .NET Core 运行时:Microsoft.AspNetCore.All 2.1.2 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]Microsoft.AspNetCore.All 2.1.9 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]Microsoft.AspNetCore.All 2.2.3 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]Microsoft.AspNetCore.App 2.1.2 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]Microsoft.AspNetCore.App 2.1.9 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]Microsoft.AspNetCore.App 2.2.3 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]Microsoft.NETCore.App 2.0.3 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]Microsoft.NETCore.App 2.0.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]Microsoft.NETCore.App 2.0.7 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]Microsoft.NETCore.App 2.0.9 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]Microsoft.NETCore.App 2.1.3-servicing-26724-03 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]Microsoft.NETCore.App 2.1.9 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]Microsoft.NETCore.App 2.2.3 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]要安装其他 .NET Core 运行时或 SDK:https://aka.ms/dotnet-download

我试过了:

  • 创建一个 global.json(

    以上所有尝试当然都涉及重新启动计算机或重新启动VS.

    解决方案

    这很可能看起来像是针对 VS 的安装程序优化,它移除了过于贪婪的旧 SDK 并移除了旧 VS 版本所依赖的版本,但目前这是MS 团队正在调查时,更多的是假设.有关更多类似报告,请参阅此 GitHub 问题.

    2.2.1xx SDK(!) 版本使用 MSBuild 15,2.2.2xx 使用 MSBuild 16.

    VS 2017 需要解析与 MSBuild 15 兼容的本地版本,因此如果在升级过程中删除了 2.2.1xx,这可能会失败.

    您可以通过重新安装兼容版本来解决此问题 - 例如2.2.105 - 来自 https://dotnet.microsoft.com/download/dotnet-core/2.2

    要了解哪个SDK使用了哪些组件,可以查看DependencyVersions.props 文件在 <3.0 源和 Versions.props 文件用于 >= 3.0(预览)源 - MSBuild 版本通过 MicrosoftBuildPackageVersion 属性设置.

    Another one of those many many similar issues, yet none of the solutions searched for, helped (see below which one are looked at).

    At the moment of writing this, .NET Core v2.2 is out of preview, the latest version being v2.2.202 (release date, 02-04-2019).

    I installed that one via "Install other frameworks", I installed the x64 one, all other versions I have installed earlier are also that version.

    After installing, when I create a new project, it shows up:

    But when I then open the properties, it does not:

    dotnet --info within the directory of the project, gives the following result:

    .NET Core SDK (reflecting any global.json):
     Version:   2.2.202
     Commit:    8a7ff6789d
    
    Runtime Environment:
     OS Name:     Windows
     OS Version:  10.0.17134
     OS Platform: Windows
     RID:         win10-x64
     Base Path:   C:Program Filesdotnetsdk2.2.202
    
    Host (useful for support):
      Version: 2.2.3
      Commit:  6b8ad509b6
    
    .NET Core SDKs installed:
      2.1.2 [C:Program Filesdotnetsdk]
      2.1.4 [C:Program Filesdotnetsdk]
      2.1.201 [C:Program Filesdotnetsdk]
      2.1.202 [C:Program Filesdotnetsdk]
      2.1.401 [C:Program Filesdotnetsdk]
      2.1.505 [C:Program Filesdotnetsdk]
      2.2.202 [C:Program Filesdotnetsdk]
    
    .NET Core runtimes installed:
      Microsoft.AspNetCore.All 2.1.2 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
      Microsoft.AspNetCore.All 2.1.9 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
      Microsoft.AspNetCore.All 2.2.3 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
      Microsoft.AspNetCore.App 2.1.2 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
      Microsoft.AspNetCore.App 2.1.9 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
      Microsoft.AspNetCore.App 2.2.3 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
      Microsoft.NETCore.App 2.0.3 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
      Microsoft.NETCore.App 2.0.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
      Microsoft.NETCore.App 2.0.7 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
      Microsoft.NETCore.App 2.0.9 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
      Microsoft.NETCore.App 2.1.3-servicing-26724-03 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
      Microsoft.NETCore.App 2.1.9 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
      Microsoft.NETCore.App 2.2.3 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
    
    To install additional .NET Core runtimes or SDKs:
      https://aka.ms/dotnet-download
    

    I have tried:

    • Create a global.json (SO answer), this only produced more errors as it could not load the project that is targeting v2.2
    • Enable preview SDKs within Settings (SO answer)
    • I have tried installing the x86 version, but that gave also more errors as it was confused about which one to use now. So that started complaining about .NET Standard not being installed.
    • I have updated Visual Studio and Visual Studio Build Tools to the latest versions, which is 15.9.11 (release date, 02-04-2019)
    • When I build via the command line dotnet build in the solution directory, it builds successfully, so it must be a visual studio thing.
    • verified that only C:Program Filesdotnet is in the Environment Variables, so C:Program Files (x86)dotnet is not present.
    • Looked at these options, did all of them but I did not set the MSBuildSDKsPath environment variable since I have other projects also in need with 2.1. I checked that there is currently no MSBuildSDKsPath set so it should not be forced to that version.

    All of the above attempts of course involving restarting the computer or restarting VS.

    解决方案

    This most likely looks like an installer optimisation for VS that removes old SDKs being too greedy and remove versions that older VS versions rely on, but at the moment this is more of an hypothesis while MS teams are investigating. See this GitHub issue for more similar reports.

    The 2.2.1xx SDK(!) versions use MSBuild 15 and the 2.2.2xx use MSBuild 16.

    VS 2017 needs to resolve a local version that is compatible with MSBuild 15 so if 2.2.1xx was removed during an upgrade, this may fail.

    You can fix this by re-installing a compatible version - e.g. 2.2.105 - from https://dotnet.microsoft.com/download/dotnet-core/2.2

    In order to find out which SDK uses which components, you can check the DependencyVersions.props file in the <3.0 sources and the Versions.props file for >= 3.0 (preview) sources - MSBuild version is set in via the MicrosoftBuildPackageVersion property.

    这篇关于当前的 .NET SDK 不支持面向 .NET Core 2.2.(SDK 2.2.202)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 06:06
查看更多