.net - dotnet 格式验证抛出 dll not found
问题描述
我想根据 .editorconfig 验证我的应用程序的代码样式。对于此任务,我在 azure (2019) ci 管道中使用本地托管代理。我只被允许使用本地提要。所以我下载了 5.1.225507 版本的 dotnet-format并将其添加到提要中。
通过 yaml 管道中的以下步骤,我尝试验证代码样式:
# working build and test here...
- task: DotNetCoreCLI@2
displayName: 'dotnet install dotnet-format'
inputs:
command: custom
custom: tool
arguments: 'update -g dotnet-format --configfile ./.nuget/NuGetBuildServer.Config'
- task: DotNetCoreCLI@2
displayName: 'Validiere Codestil'
inputs:
command: custom
custom: format
arguments: '-v diag --configfile ./.nuget/NuGetBuildServer.Config --check --verbosity diagnostic --no-restore --verify-no-changes --severity info'
# working publishing here...
安装错误的运行时失败并出现错误。如何告诉 dotnet 使用 sdk 作为运行时?它已安装:
[command]C:\dotnet\dotnet.exe --list-sdks
5.0.201 [C:\dotnet\sdk]
解决方案
要使 SDK 在本地使用最新安装的版本,您需要在 global.json 文件中指定该版本。
如果未找到global.json中指定的 SDK,.NET CLI 将使用匹配规则来选择兼容的 SDK,如果找不到,则失败。
global.json 语法:
{
"sdk": {
"version": "5.0.0"
}
}
推荐阅读
- django - Django - 我应该为我的案例使用什么 CBV?
- angular - 两个连接到不同路由文件的路由器出口
- asp.net - 如何使用转换更新 Web.Config 中的部分?
- google-cloud-platform - 将所有流式传输到 bigquery 的数据
- mongodb - 猫鼬在哪里算
- javascript - 字符类中的范围乱序 - 正则表达式
- vba - 如何对多个工作表中的一系列值求和
- java - Jmeter - 单击查看结果树中的响应时出现 java 异常
- html - 使用 Google AppEngine 托管静态网站时出现 404 错误
- rest - PDI - 水壶、REST API 使用错误