asp.net-core - ASP.NET Core:未找到 global.json 版本 2.1.400 的兼容 SDK 版本
问题描述
我的解决方案中有一个面向 .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 列表中?
解决方案
我终于发现dotnet
在 Team City 上运行时不被识别为命令(尽管dotnet
在相同的 Windows 帐户下被识别为提示符中的命令)。
我的解决方案是PATH
使用 Team City 参数更新环境变量:
Name: env.PATH
Kind: Environment Variable
Value: C:\Program Files\dotnet;%env.PATH%
它现在按预期工作。
推荐阅读
- python - IndexError:索引 100 超出轴 0 的范围,大小为 8
- redis - Redis 未在 Codeship 中加载
- python - Keras 训练进度条在一条线上,带有纪元数
- python-3.x - 如何从 nlp 中的数据框列中删除 http URL 链接
- react-native - 如何修复“未定义不是对象(评估'Object.keys(routeConfigs)')”
- python - 需要修改我的正则表达式以在每个新行处拆分字符串
- ruby-on-rails - Rails 中的全局“current_utc_time”函数是一个“坏”主意吗?
- vbscript - 使用 VBscript 和 For 循环卡住填充数组
- java - Spring Boot:如何获取 Web 服务器根 url
- javascript - 尝试将数组拆分为字符数组时出现间歇性类型错误