I want to validate the code style of my application according to the .editorconfig. For this task I use a local hosted agent in an azure (2019) ci pipeline. I'm only allowed to use local feeds. So I downloaded dotnet-format in version 5.1.225507 and added it to the feed.
With the following steps in the yaml pipe I try to validate the code style:
# 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...
It fails with error that the wrong runtime is installed. How to tell dotnet to use the sdk as runtime? It is installed:
[command]C:\dotnet\dotnet.exe --list-sdks
5.0.201 [C:\dotnet\sdk]
Solved my issue. The problem was dotnet format
looks for the location of the SDK in the default location. The runtime environment was installed in a custom directory instead. To point to the correct version the variable "DOTNET_ROOT" has to be set. Added to the variables:
- name: dotnet_root
value: C:\path\to\.net5.0\
This added the variable in the runner.