Doing Build instead of Rebuild

Title: Doing Build instead of Rebuild

Body:
Hi,

I’m using the SonarQube MSBuild scanner (v11.0.0) with my .NET solution. Currently, I run a full Rebuild for the first analysis, and then only Build for subsequent runs. Doing a full Rebuild on every analysis is quite time-consuming, so I’d prefer to avoid it if possible.

My questions are:

  • Is it safe to do this, or do I need to Rebuild every time?

  • If I only do Build, will SonarQube Server keep the results for projects that MSBuild skips as up-to-date?

  • How does SonarQube distinguish between a project that was just skipped (because it didn’t need recompilation) and one that was actually deleted from the solution?

Hi,

Welcome to the community!

The rules are run during the build itself, so only the code that gets built is analyzed. You may think “cool! incremental analysis” but what if your incremental change that gets built/analyzed has cascading effects into unchanged parts of the code? Not re-building that code is fine, but not re-analyzing it? Probably not so much.

So in short, you should rebuild each time.

 
HTH,
Ann