Csc.exe error om MSBuild Rebuild

Must-share information (formatted with Markdown):

  • how is SonarQube deployed: AWS enterprise
  • what are you trying to achieve: code scan
  • what have you tried so far to achieve this: issue looks to be in msbuild rebuild - we’ve tried dotnet scanner .net version 6.1 + 5.15 and both have same error

SonarScanner.MSBuild.exe begin
MSBuild.exe Rebuild

Error only occurs on two projects out of 50+
.nuget\packages\\2.1.0\tools\Microsoft.CSharp.Core.targets(71,5): error MSB60
06: “csc.exe” exited with code 1.

All projects using same .NET version and compiler etc

Normal MSBuild 16.11 compiles whole solution with no issue

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!


To be clear, are you saying that you get a compile error when you’ve run the begin command before compile - and only then? Running an independent compile works fine?

And can you provide full, debug logs?

Share the Scanner for .NET verbose logs

  • Add /d:"sonar.verbose=true" to the…
    • SonarScanner.MSBuild.exe or dotnet sonarscanner begin command to get more detailed logs
      • For example: SonarScanner.MSBuild.exe begin /k:"MyProject" /d:"sonar.verbose=true"
    • “SonarQubePrepare” or “SonarCloudPrepare” task’s extraProperties argument if you are using Azure DevOps
      • For example:
        - task: SonarCloudPrepare@1
              SonarCloud: 'sonarcloud'
              organization: 'foo'
              scannerMode: 'MSBuild'
              projectKey: 'foo_sonar-scanning-someconsoleapp'
              projectName: 'sonar-scanning-someconsoleapp'
              extraProperties: |
  • The important logs are in the END step (i.e. SonarQubeAnalyze / SonarCloudAnalyze / “Run Code Analysis”)

Share the msbuild detailed logs

MsBuild.exe /t:Rebuild /v:d


dotnet build -v:d


Hi, I’m consious of uploading our detailed build logs here - is there another way we can send over to you? Thanks


Feel free to redact them as necessary.