为什么我无法运行dotnet工具安装--global bla-bla-bla? [英] Why am I unable to run dotnet tool install --global bla-bla-bla?
问题描述
具体来说,我正在尝试运行 dotnet工具安装--global Project2015To2017.Migrate2017.Tool
,如此处所述- https://github.com/hvanbakel/CsprojToVs2017#as-a-net-core-global-tool
Specifically, I am trying to run dotnet tool install --global Project2015To2017.Migrate2017.Tool
as explained here - https://github.com/hvanbakel/CsprojToVs2017#as-a-net-core-global-tool
这是我得到的:
c:\Program Files\dotnet\sdk\2.1.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets(135,5): error : The current .NET SDK does not support targeting .NET Core 2.1. Either target .NET Core 2.0 or lower, or use a version of the .NET SDK that supports .NET Core 2.1. [C:\Users\mkharitonov\AppData\Local\Temp\3sdfphfy.fq0\restore.csproj]
The tool package could not be restored.
Tool 'project2015to2017.migrate2017.tool' failed to install. This failure may have been caused by:
* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET Core tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.
所以,我去了 https://www.microsoft.com/net/download/dotnet-core/2.1 并安装了SDK 2.1的.NET Core安装程序x64 .500。如果此方法不起作用,我为Runtime 2.1.6安装了相同的工具(不要认为它有任何作用)。无论如何,错误消息仍然存在,我不知道该怎么办。
So, I went to https://www.microsoft.com/net/download/dotnet-core/2.1 and installed the .NET Core Installer x64 of SDK 2.1.500. When this did not work I installed the same for Runtime 2.1.6 (do not think it did anything). Anyway, the error message stays and I have no idea what am I expected to do.
编辑1
C:\xyz\MyApp [master ≡]> dotnet --list-sdks
1.0.0-preview2-003131 [C:\Program Files\dotnet\sdk]
2.1.4 [C:\Program Files\dotnet\sdk]
2.1.403 [C:\Program Files\dotnet\sdk]
2.1.500 [C:\Program Files\dotnet\sdk]
编辑2
C:\xyz\MyApp [master ≡]> dotnet new globaljson --sdk-version 2.1.500
The template "global.json file" was created successfully.
C:\xyz\MyApp [master ≡ +1 ~0 -0 !]> cat .\global.json
{
"sdk": {
"version": "2.1.500"
}
}
C:\xyz\MyApp [master ≡ +1 ~0 -0 !]> dotnet tool install --global Project2015To2017.Migrate2017.Tool
c:\Program Files\dotnet\sdk\2.1.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets(135,5): error : The current .NET SDK does not support targeting .NET Core 2.1. Either target .NET Core 2.0 or lower, or use a version of the .NET SDK that supports .NET Core 2.1. [C:\Users\mkharitonov\AppData\Local\Temp\lrfiazvp.bxe\restore.csproj]
The tool package could not be restored.
Tool 'project2015to2017.migrate2017.tool' failed to install. This failure may have been caused by:
* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET Core tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.
C:\xyz\MyApp [master ≡ +1 ~0 -0 !]>
编辑3
C:\Users\mkharitonov\AppData\Local\Temp> dotnet --list-sdks
1.0.0-preview2-003131 [C:\Program Files\dotnet\sdk]
2.1.4 [C:\Program Files\dotnet\sdk]
2.1.403 [C:\Program Files\dotnet\sdk]
2.1.500 [C:\Program Files\dotnet\sdk]
C:\Users\mkharitonov\AppData\Local\Temp> Test-Path global.json
False
C:\Users\mkharitonov\AppData\Local\Temp> cd ..
C:\Users\mkharitonov\AppData\Local> Test-Path global.json
False
C:\Users\mkharitonov\AppData\Local> cd ..
C:\Users\mkharitonov\AppData> Test-Path global.json
False
C:\Users\mkharitonov\AppData> cd ..
C:\Users\mkharitonov> Test-Path global.json
False
C:\Users\mkharitonov> cd ..
C:\Users> Test-Path global.json
False
C:\Users> cd ..
C:\> Test-Path global.json
False
C:\>
推荐答案
您可以运行 dotnet工具安装具有诊断详细程度。
例如:
You can run dotnet tool install with diagnostic verbosity level. For example:
dotnet tool install --global Project2015To2017.Migrate2017.Tool -v diag
我遇到了一些问题,在我的情况下,我遇到了错误:
I had some problem and in my case I had error:
The SDK 'Microsoft.NET.Sdk' specified could not be found
为解决此问题,我更改了环境变量 MSBuildSDKsPath (来自的建议https://github.com/Microsoft/msbuild/issues/2532 )
To solve this problem I changed environment variable MSBuildSDKsPath (advice from https://github.com/Microsoft/msbuild/issues/2532)
这篇关于为什么我无法运行dotnet工具安装--global bla-bla-bla?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!