Building dotNet 5 and net core 3.1.x apps

Hi guys, i facing a problem in this enviroment

  • Azure DevOps to run my pipeline
  • Bitbucket as code repository.
  • the error raised when → Running task DotNetCoreCLI@2 after SonarCloudPrepare@1
  • Language C#

trying to build and connect my pipeLine with sonarCloud i have a .net 5.0.x project and .net core 3.1.x , when build the project normally works ok , but when start to add the sonar cloud task starst to fail.

with the next yalm my build is working fine :

trigger:

  • qa
  • develop
  • master

resources:

  • repo: self

variables:
tag: ‘$(Build.BuildId)’

stages:

  • stage: Build
    displayName: Build image
    jobs:
    • job: Build
      displayName: Build
      pool:
      vmImage: ‘windows-latest’
      steps:

      • task: UseDotNet@2
        displayName: ‘Install .NET 5.x.x SDK’
        inputs:
        version: ‘5.0.x’
        performMultiLevelLookup: true
        includePreviewVersions: true # Required for preview versions

      • task: UseDotNet@2
        displayName: Use Dot Net Core 3.1.x
        inputs:
        packageType: ‘sdk’
        version: ‘3.1.x’

      • task: DotNetCoreCLI@2
        inputs:
        command: ‘build’
        projects: ‘**/*.sln’
        displayName: ‘dotnet build’

But when i add SonarCloudPrepare@1 before my build :

trigger:

  • qa
  • develop
  • master

resources:

  • repo: self

variables:
tag: ‘$(Build.BuildId)’

stages:

  • stage: Build
    displayName: Build image
    jobs:
    • job: Build
      displayName: Build
      pool:
      vmImage: ‘windows-latest’
      steps:

      • task: UseDotNet@2
        displayName: ‘Install .NET 5.x.x SDK’
        inputs:
        version: ‘5.0.x’
        performMultiLevelLookup: true
        includePreviewVersions: true # Required for preview versions

      • task: UseDotNet@2
        displayName: Use Dot Net Core 3.1.x
        inputs:
        packageType: ‘sdk’
        version: ‘3.1.x’

      • task: SonarCloudPrepare@1
        inputs:
        SonarCloud: ‘tp-survey’
        organization: ‘teleperformance-sonarcloud’
        scannerMode: ‘MSBuild’
        projectKey: tp-cm-back-survey
        projectName: ‘tp-cm-back-survey’
        extraProperties: |
        sonar.exclusions="/bin//,/obj//,/Migrations/,/*.dll"
        sonar.coverage.exclusions="test/
        "
        sonar.cs.roslyn.ignoreIssues=true
        sonar.verbose=true

      • task: DotNetCoreCLI@2
        inputs:
        command: ‘build’
        projects: ‘**/*.sln’
        displayName: ‘dotnet build’

I getting this error :

Command-line syntax error : ‘D:\a\1\s\TPSurveyUnitTest\bin\Debug.netcoreapp,version=v5.0\TPSurveyUnitTest.dll.RoslynCA.json’ is not a valid value for the ‘/errorlog:’ option. The value must be of the form ‘[,version={1|1.0|2|2.1}]’. [D:\a\1\s\TPSurveyUnitTest\TPSurveyUnitTest.csproj]
181 Warning(s)
1 Error(s)

I trying installing before the sonarPrepare task the net core version 2.1.x, , restore task and the result is the same.

Can you help me with this ?

Thanks in advance.

@Ivalberto is this exactly the same issue as the one you created in this thread? If so, please close one of them.

What is the value of TargetFramework in your project file?

I can reproduce a similar error when if I manually set the TargetFramework to .netcoreapp,version=v5.0.

However, if I create a new .NET 5 project using VS/dotnet new the TargetFramework is <TargetFramework>net5.0</TargetFramework>.

Did you originally create the project with a preview version of VS/.NET5?

2 Likes

This topic was automatically closed after 6 days. New replies are no longer allowed.