How to handle conditional compilation or multi-platform compilation?


I’m analyzing a C# project using GitHub actions. The language and the ALM does not really matter in this case as it’s a general question.

In my CI workflow for new PRs I would like to trigger multiple builds (for different IFDEFs or on different platforms) to test all available codepaths.

Sadly, each new report overwrites the previous one.

How can we handle this scenario while:

  • Having one PR comment per configuration
  • Having a single report on the SonarCloud website


Hi Florian,

Unfortunately, we don’t have great answers for you. We’re aware that the problem exists across multiple languages. We’ve been strategizing about how to handle it, but don’t have solutions yet. The best thing you can do here is probably to analyze each IFDEF as a separate branch. That gets you:

  • no overwrite
  • one report per configuration
  • multiple reports on SonarCloud

Yes, I know one of those things is not what you wanted.


Hey, thanks for your reply.

Multiple branches and multiple PRs will unfortunately complicate the workflow processes way too much. I guess for now there is no good way to automatically analyze our codebase with SonarCloud. Good thing this is on your list.

From a technical side of view, wouldn’t it be possible to add an additional argument to the sonarscanner that acts as an aggregation key? For example, if I would start 3 scan tasks using the same token (which could be the commit hash in my case), shouldn’t it be possible to merge the results of all these scans?


As a coder, I guess you know that anything’s possible given enough time & money. :joy:

I’m not saying what you’ve suggested will never happen, but it would be a significant re-architecting.