SonarQube in Azure DevOps build fails and appears to break the build agent too

My team uses local Azure build agents via Azure DevOps and I just started working on integrating SonarQube analysis into my YAML file.

The build with SonarQube is failing - an Error CS0234: The type or namespace name ‘Foo’ does not exist in the namespace ‘Bar’ (are you missing an assembly reference?) - the build worked on the build agents before I added the SonarQube Prepare task, so there must be something wrong with my configuration - any ideas?

Also, now that the build agent has failed I tried remove the SonarQube steps BUT the build still fails and I still see build output like “Sonar: (FooBar.csproj) Project processed successfully”. I have to manually delete the .sonarqube folder on the build agent, which is a pain - is there an easier way to “turn off” the “SonarQube prepare” (that .sonarqube folder) for that build on the build agent(s) that have ran SonarQube Prepare at least once?

I do have one more “interesting” thing - the project is built using a “dotnet publish” on a .wixproj to create an installer. My ‘Release’ configuration only builds the .wixproj and that project has a “BeforeBuild” to “dotnet publish MyWebsite.cproj…”. Like I said, this works fine if I do not “SonarQube Prepare”.

I just changed the ‘Release’ configuration to build all the .csproj and NOT build the .wixproj, and now the build does succeed, but I don’t get the MSI file output which I need.

Anyone have some advice on how to get SonarQube to work with a build from “dotnet publish” ? Maybe I need some special SQ config setting?

Hello @jeoffh and welcome to the community.

Apologies for the late reply. Did you find the issue or do you still have this problem?

If still having the problem, can you share the verbose logs with us?

  • run the begin step with /d:sonar.verbose=true parameter
  • run the build with -v:diag

Does it do a full rebuild each time? Because you need to do a full build for the analysis to work.

Hello Andrei, thank you for the response.

Yes, the Azure DevOps build is set to clean all outputs so it should be a full rebuild.

We found a workaround for the issue is to basically build everything twice…

The “wixproj” is doing a “dotnet publish…” on its own BeforeBuild to generate the .msi. Since the dotnet publish builds everything, we set the wixproj to be the only project built for “Release” configuration and I guess this confuses SQ. We changed Release to now build all the rest of the projects (in addition to wixproj) and now SQ is happy. This adds another few minutes to the build, which is unfortunate if necessary I guess.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.