SonarQube MSBuild Issues - new user here

Good Afternoon Everyone,

I am a new SonarQube user who has successfully conducted code analysis using my current SonarQube configuration on simple “hello world” type .NET projects.

I get errors however during the “sonar-scanner-msbuild-\SonarScanner.MSBuild.exe begin” step when I attempt to analyze projects with many “…\packages” references in the analyzed project’s .csproj file. Errors are related to missing “…\packages” content .

I assume that I may be missing a NuGet component or other plugin but am not sure. I am using Visual Studio 2019 Professional for MSBuild and my sonar-scanner version is shown above.

Any help would be much appreciated. As stated above, I’m new to SonarQube and my .NET development experience is dated as well.

Thank you very much.


Can you share the exact error message and where it appears in the process of your scan/build (the more logs you can share, the more we can help!)


Thank you for your reply. Please note that for the specific error detailed below I changed the “…\packages\OctoPack.3.5.2\build\OctoPack.targets” reference path in my .csproj file to get past that specific error. However other “…\packages” files were missing and created new errors. I hope that makes sense.

Here are the error results from starting step to point of error:

C:\Users\CMD\Downloads\Test14>C:\Users\CMD\Downloads\sonar-scanner-msbuild-\SonarScanner.MSBuild.exe begin /k:“sample14” /n:“sample14” /v:“1.0”
SonarScanner for MSBuild 4.6
Using the .NET Framework version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories…
07:58:30.854 Updating build integration targets…
07:58:30.885 Fetching analysis configuration settings…
07:58:32.432 Provisioning analyzer assemblies for cs…
07:58:32.432 Installing required Roslyn analyzers…
07:58:32.87 Provisioning analyzer assemblies for vbnet…
07:58:32.87 Installing required Roslyn analyzers…
07:58:32.901 Pre-processing succeeded.

C:\Users\CMD\Downloads\Test14>“C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe” /t:Rebuild
Microsoft ® Build Engine version 16.0.461+g6ff56ef63c for .NET Framework
Copyright © Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the “-m” switch.
Build started 6/12/2019 7:58:59 AM.
Project “C:\Users\CMD\Downloads\Test14\Service.sln” on node 1 (Rebuild target(s)).
Building solution configuration “Debug|Any CPU”.
Project “C:\Users\CMD\Downloads\Test14\Service.sln” (1) is building “C:\Users\CMD\Downloads\Test14
\Service\Service.csproj” (2) on node 1 (Rebuild target(s)).
Creating directory “obj\Debug”.
C:\Users\CMD\Downloads\Test14\Service\Service.csproj(210,5): error : This project referen
ces NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more informati
on, see The missing file is …\packages\OctoPack.3.5.2\build\OctoPack.ta
Done Building Project “C:\Users\CMD\Downloads\Test14\Service\Service.csproj” (Rebuild tar
get(s)) – FAILED.

Project “C:\Users\CMD\Downloads\Test14\Service.sln” (1) is building “C:\Users\CMD\Downloads\Test14
\Service.Tests.Integration\Service.Tests.Integration.csproj” (3) on node 1 (Rebuild target(s)
Creating directory “obj\Debug”.
Creating directory “…\tests\Integration”.
Done Building Project “C:\Users\CMD\Downloads\Test14\Service.Tests.Integration\Service.Te
sts.Integration.csproj” (Rebuild target(s)) – FAILED.

Done Building Project “C:\Users\CMD\Downloads\Test14\Service.sln” (Rebuild target(s)) – FAILED.


“C:\Users\CMD\Downloads\Test14\Service.sln” (Rebuild target) (1) ->
“C:\Users\CMD\Downloads\Test14\Service\Service.csproj” (Rebuild target) (2) ->
(EnsureNuGetPackageBuildImports target) ->
C:\Users\CMD\Downloads\Test14\Service\Service.csproj(210,5): error : This project refer
ences NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more informa
tion, see The missing file is …\packages\OctoPack.3.5.2\build\OctoPack.

0 Warning(s)
1 Error(s)

Time Elapsed 00:00:00.76


It looks like “just” the build step is failing (to confirm, try running the build without any of the SonarQube Scanner for MSBuild steps, I expect you’d still see it fail)

You probably just need to run a nuget restore (see some documentation here) before running your build/analysis.

1 Like

Thanks again for your reply. I ran dotnet restore command in an updated test folder and received the following “Nothing to do” message. This doesn’t make sense as the .csproj file is included in the files.

C:\Users\CMD\Downloads\Test16>dotnet restore
Nothing to do. None of the projects specified contain packages to restore.