SonarCloud + PostSharp crashes SonarCloudAnalyze@2

  • ALM used: Azure DevOps
  • CI system used: Azure DevOps
  • Scanner command used when applicable:
- task: SonarCloudPrepare@2
  displayName: 'Configure SonarCloud without OWASP'
  inputs:
    SonarCloud: *******
    organization: *******
    scannerMode: 'MSBuild'
    projectKey: *******
    projectName: *******
    extraProperties: |
      sonar.verbose=true
      sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/*.trx
      sonar.cs.opencover.reportsPaths=$(Agent.TempDirectory)/*/coverage.opencover.xml

- task: SonarCloudAnalyze@2
  displayName: "SonarCloud Analyze"

- task: SonarCloudPublish@2
  displayName: "SonarCloud Publish"
  inputs:
    pollingTimeoutSec: '300'
  • Languages of the repository: C#, html, js, TS, scss (issue is rather related to C# code)
  • Error observed
10:26:01.016 INFO: CPD Executor CPD calculation finished (done) | time=832ms
10:26:01.105 DEBUG: Shutting down the worker
10:26:01.107 INFO: Rule | Time (ms) | Relative
10:26:01.107 INFO: :----|----------:|--------:
10:26:01.143 DEBUG: The worker thread exited with code 0
10:26:01.147 DEBUG: The bridge server shut down
10:26:01.148 INFO: Rule | Time (ms) | Relative
10:26:01.148 INFO: :----|----------:|--------:
10:26:02.976 INFO: ------------------------------------------------------------------------
10:26:02.976 INFO: EXECUTION FAILURE
10:26:02.976 INFO: ------------------------------------------------------------------------
10:26:02.977 INFO: Total time: 2:39.909s
10:26:03.141 INFO: Final Memory: 108M/364M
10:26:03.141 INFO: ------------------------------------------------------------------------
##[error]10:26:03.142 ERROR: Error during SonarScanner execution
10:26:03.142 ERROR: Error during SonarScanner execution
10:26:03.168 DEBUG: Cleanup org.eclipse.jgit.util.FS$FileStoreAttributes$$Lambda$288/0x00000173102f8ec8@1de0a46c during JVM shutdown
Process returned exit code 1
##[error]The SonarScanner did not complete successfully
The SonarScanner did not complete successfully
##[error]10:26:03.677  Post-processing failed. Exit code: 1
10:26:03.677  Post-processing failed. Exit code: 1
##[warning]Can't find loc string for key: LIB_ProcessExitCode
##[warning]Error while executing SonarCloud:Analyze task: LIB_ProcessExitCode D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\2.2.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe 1
##[error]LIB_ProcessExitCode D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\2.2.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe 1
Finishing: SonarCloud Analyze

  • Steps to reproduce
    Execute pipeline with both PostSharp and SonarCloud enabled. If we disable PostSharp execution during build via “SkipPostSharp” msbuild param, everything goes smooth, so it needs to be some kind of conflict between PostSharp and SonarCloud

Unfortunately, I’ve been not able to find anything useful in both build logs and SonarCloudAnalyze logs, it just fails with “Post-processing failed” without giving any detailed reason, even with verbose logging turned on. The package we’re using Getting Started with PostSharp Logging is attached to all projects within solution (including tests) and LogAttribute is injected to most of the code via config.

Hey @paweltichoniuk

To be honest, we have no experience with PostSharp over here. It could just as easily be a problem on their side. :smiley:

But assuming it is something we have control over, it would be great to have your full DEBUG analysis logs (from SonarQubeAnalyze).

It’s really surprising that if there’s an issue, it would come after the build. At this point in the scan… it’s just a Java process that does not care about your build.

42.txt (6.0 MB)

Hi Colin
I’ve attached the entire dump from SonarCloudAnalyze. Our entire PR pipeline passes as expected (including build/unit tests) when PostSharp is enabled. As far as I understand the way it’s working, it modifies dlls on-the-fly (How Does PostSharp Work). The issue could be some kind hash/version of check that Sonar may be executing on output dlls (or something similar), as it basically crashes at the very end. I was hoping that verbose logs will give us any clues on where it is crashing, but doesn’t seem so.

As for “generating” the crash, it would be as easy as just adding PostSharp nuget to the project, adding the aspects to few classes (either via attribute or config file xml, so it has anything to attach) and observe the problem, nothing fancy.

Thanks.

I’ll work on a reproducer (although I’m limited to my Mac today). There is one thing in the meantime I’d like you to try (just to continue to rule out possibilities)

Calculating the SCM revision ID is next in analysis. Just for giggles, can you try setting sonar.scm.disabled=true to see if that changes the behavior?

INFO: SCM revision ID 'c657681f380f9c01ef84cfcde647a88b89572ae9'
INFO: Analysis report generated in 41ms, dir size=566.0 kB
INFO: Analysis report compressed in 35ms, zip size=138.7 kB
INFO: Analysis report uploaded in 358ms

Yep, will do it today. Just tweaked up pipeline parameters and triggered the pipeline run. We’ll see if that changes anything.

Results (it succeeded after disabling SCM):
testRun.txt (7.0 MB)

Looking on what SCM does (SCM integration), could it be a case that it needs to execute on dlls (if it’s operating on dlls), that were not yet affected by PostSharp aspects processing? There should be a subfolder, where PostSharp copies over original dlls. If that’s the case, for any step that needs dlls unaffected by PostSharp, we’ll have to point it to that specific directory (Before-PostSharp).

Hey there.

I do intend to come back to this thread. I just want to stop by and say that the Scanner really shouldn’t care about .dll files at all, which is why I find this such a headscratcher.