Sonarqube Scanner holds files after scan

Hi Team,

I’ve multiple builds in the same pipeline(TeamCity). I’m getting below error while scanning

Scanner Version is 4.8 & SonarQube version is 9.2.4

[11:53:23]Cannot copy a different version of the SonarScanner for MSBuild assemblies because they are used by a running MSBuild/.Net Core process. To resolve this problem try one of the following:
[11:53:23]- Analyze this project using the same version of SonarScanner for MSBuild
[11:53:23]- Build your project with the ‘/nr:false’ switch
[11:53:23]Pre-processing failed. Exit code: 1
[11:53:23]Process exited with code 1

I’ve passed /p:SonarQubeTargetsImported=true to avoid this error, but now I’m getting

[11:57:41]11:57:41.032 11:57:41.029 Unrecognized command line argument: /p:SonarQubeTargetsImported=true
[11:57:41]11:57:41.032 Expecting at least the following command line argument:
[11:57:41]- SonarQube project key
[11:57:41]When connecting to a SonarQube server earlier than version 6.1, the following command line arguments are also required:
[11:57:41]- SonarQube project name
[11:57:41]- SonarQube project version
[11:57:41]The full path to a settings file can also be supplied. If it is not supplied, the exe will attempt to locate a default settings file in the same directory as the SonarQube Scanner for MSBuild.
[11:57:41]Use ‘/?’ or ‘/h’ to see the help message.
[11:57:41]11:57:41.034 Pre-processing failed. Exit code: 1
[11:57:41]Process exited with code 1

HI @Shoaib_Bepari - welcome to the community.

  1. try upgrading to the latest version of the SonarScanner for .Net (currently v5.5.3). The version you are using is quite old, and there have been an number of bug fixes since that affect running multiple builds.

  2. If that doesn’t work, try the workaround suggested in the output you quoted above:

FYI the files locks are being held by an MSBuild process that continues running after the first build completes. The /nr:false switch tells MSBuild not to use the long-running MSBuild process.

  1. /p:SonarQubeTargetsImported…

You are passing the argument to the wrong process - it should be passed to MSBuild, not to the scanner.

I’ve attached image for you’re reference.

/nr:false is not working, same error files are in use.


Have you tried using the latest version of the scanner? Your image is still referring to v4.8.

Also, according to the image you are still passing SonarQubeTargetsImported argument to the scanner, which is incorrect.

This topic was automatically closed after 10 days. New replies are no longer allowed.