在dotnet core SDK版本之间切换 [英] Switch between dotnet core SDK versions

查看:684
本文介绍了在dotnet core SDK版本之间切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近安装了VS 2017 RC,然后自动将我的dotnet版本指向 1.0.0-preview4-004233 。因此,每当我使用命令 dotnet new -t Console 创建一个新项目时,尽管我看不到 project.json 参见 .csproj 文件。

I recently installed VS 2017 RC and then automatically my dotnet version pointed to 1.0.0-preview4-004233. Due to that whenever I create a new project using command dotnet new -t Console I cannot see project.json though I see .csproj file.

当我检查计算机上可用的dotnet版本时,位于- C:\Program Files\dotnet checksdk 我看到多个版本可用。

When I check dotnet versions available on my machine at - C:\Program Files\dotnet\sdk I see multiple versions available.

有什么方法可以将dotnet核心切换回早期版本- 1.0.0-preview2-003133 1.0.0-preview4-004233 无需卸载。

Is there any way to switch dotnet core back to an earlier version - 1.0.0-preview2-003133 from 1.0.0-preview4-004233 without uninstalling.

推荐答案

您可以使用项目根目录中的 global.json 文件执行此操作:

You can do this with a global.json file in the root of your project:


  • 验证计算机上的SDK列表:

dotnet --list-sdks

您会看到这样的列表。

2.1.100 [C:\Program Files\dotnet\sdk]
2.1.101 [C:\Program Files\dotnet\sdk]
2.1.103 [C:\Program Files\dotnet\sdk]
2.1.104 [C:\Program Files\dotnet\sdk]
[...lines omitted...]
2.1.601 [C:\Program Files\dotnet\sdk]
2.2.101 [C:\Program Files\dotnet\sdk]
3.0.100-preview3-010431 [C:\Program Files\dotnet\sdk]




  • 创建一个文件夹,将其作为项目的根目录运行 dotnet new

  • 在该文件夹中,运行以下命令: dotnet new globaljson

    • Create a folder to be the root of your project, where you are going to run dotnet new.
    • In that folder, run this command: dotnet new globaljson
    • 结果如下所示:

      {
        "sdk": {
          "version": "3.0.100-preview3-010431"
        }
      }
      




      • 版本中,替换 3.0.100-preview3-010431 ,并从-list-sdks 列表中选择您喜欢的版本。例如:

        • In version, replace the 3.0.100-preview3-010431 with the version you prefer from the --list-sdks list. For example:
        • {
            "sdk": {
              "version": "2.2.101"
            }
          }
          




          • 运行 dotnet --version 进行验证。您应该看到:

            • Run dotnet --version to verify. You should see:
            • 2.2.101
              




              • 运行适当的 dotnet new 命令来创建项目。 / li>

                • Run the appropriate dotnet new commands to create your project.
                • 这篇关于在dotnet core SDK版本之间切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆