-1

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]
finder2
  • 842
  • 1
  • 11
  • 30
  • The error tells you **exactly** what the problem is: your agent doesn't have the required .NET runtime version installed. – Ian Kemp Sep 07 '21 at 09:17
  • yeah but i build for .net 5.0.x and this works fine. Why does this error occur? AFAIK .net core was included in .net 5.0. Do i need to tell him to use another version? – finder2 Sep 07 '21 at 09:25
  • Congratulations, your code runs on .NET 5.0. **dotnet-format does not**, hence the error message. **Which you should read.** – Ian Kemp Sep 07 '21 at 09:26
  • fixed my question. How do i use my installed sdk as runtime? or does the sdk doesn't contain the rutime? – finder2 Sep 07 '21 at 09:35

1 Answers1

0

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.

finder2
  • 842
  • 1
  • 11
  • 30