我的解决方案中有一个面向 .NET Core 2.1 的 ASP.NET Core 项目。我在解决方案级别添加了一个 global.json 文件:
{
"sdk": {
"version": "2.1.400"
}
}
在 Team City 代理上,我安装了 MSBuild Tools 2017 (15.8.1),包括 .NET Core Build Tools。
从命令行我可以看到代理上安装了 SDK 2.1.400:
>dotnet --list-sdks
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.400 [C:\Program Files\dotnet\sdk]
但是,在 Team City 上构建解决方案失败,并出现以下错误:
dashboard.csproj : error : Unable to locate the .NET Core SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version.
Dashboard.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.
A compatible SDK version for global.json version: [2.1.400] from [X:\agent-1\sandbox1\global.json] was not found
知道为什么在使用 MSBuild 构建时找不到 SDK 2.1.400(假设 SDK 2.1.400 存在于 SDK 列表中)吗?
最佳答案
我最终发现,在 Team City 上运行时,dotnet
未被识别为命令(尽管在同一 Windows 下,dotnet
被提示符识别为命令)帐户)。
我的解决方案是使用 Team City 参数更新 PATH
环境变量:
Name: env.PATH
Kind: Environment Variable
Value: C:\Program Files\dotnet;%env.PATH%
现在它可以按预期工作。
关于asp.net-core - ASP.NET Core : A compatible SDK version for global. json 版本 2.1.400 未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52076787/