dotnet 格式验证抛出 dll 未找到
dotnet format validation throws dll not found
我想根据.editorconfig 验证我的应用程序的代码风格。对于此任务,我在 azure (2019) ci 管道中使用本地托管代理。我只被允许使用本地提要。所以我下载了dotnet-format 5.1.225507 版本并将其添加到提要中。
我尝试在 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 使用 matching rules 到 select 兼容的 SDK ,或者如果找到 none 则失败。
global.json 语法:
{
"sdk": {
"version": "5.0.0"
}
}
参考:
Select which .NET version to use - .NET | Microsoft Docs
解决了我的问题。问题是 dotnet format
在默认位置查找 SDK 的位置。运行时环境安装在自定义目录中。要指向正确的版本,必须设置变量“DOTNET_ROOT”。添加到变量:
- name: dotnet_root
value: C:\path\to\.net5.0\
这在运行器中添加了变量。
我想根据.editorconfig 验证我的应用程序的代码风格。对于此任务,我在 azure (2019) ci 管道中使用本地托管代理。我只被允许使用本地提要。所以我下载了dotnet-format 5.1.225507 版本并将其添加到提要中。
我尝试在 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 使用 matching rules 到 select 兼容的 SDK ,或者如果找到 none 则失败。
global.json 语法:
{
"sdk": {
"version": "5.0.0"
}
}
参考: Select which .NET version to use - .NET | Microsoft Docs
解决了我的问题。问题是 dotnet format
在默认位置查找 SDK 的位置。运行时环境安装在自定义目录中。要指向正确的版本,必须设置变量“DOTNET_ROOT”。添加到变量:
- name: dotnet_root
value: C:\path\to\.net5.0\
这在运行器中添加了变量。