Our code repositories are hosted in Github, but we use TeamCity to build our code. I am in the process of setting up our SonarCloud uploads for all of our 22 repositories and I have succeeded in using dotnet sonarscanner to upload most of the repositories, but some are, due to legacy code, building a bit different, and I have trouble with the uploads to SonarCloud.
I run this command to start dotnet sonarscanner
C:\Program Files\dotnet\dotnet.exe sonarscanner begin /k:"STAR-Code_jobag" /o:"star-code" /d:sonar.token="8d730fb433f3ae3290c5a5926d144ea9a77f60a1" /d:sonar.host.url="[https://sonarcloud.io](https://sonarcloud.io/)" /d:sonar.branch.name="2024-1/master" /d:sonar.verbose="true" from D:\TC\A2\work\8db6c7b507676697\JobAg\JobAg
then I run these commands to build the solution:
RemoveFiles -Files $logFiles
Invoke-Expression "& $NugetExePath restore $MSBuildProjFile"
$msbArgs = "/nr:false /noconlog /nologo /m $(
)/flp1:Verbosity=Detailed;LogFile=$logDebug /flp2:errorsonly;LogFile=$logError $(
)/p:Configuration=$configuration /p:Platform=""Any CPU"" $(
)$MSBuildProjFile";
RunMSBuild -Arguments "/t:clean,build $msbArgs" -WorkingDir $slnDir -latestInstalled $true
and finally, I run this command end sonarscanner
C:\Program Files\dotnet\dotnet.exe sonarscanner end /d:sonar.token="TOKEN" from D:\TC\A2\work\8db6c7b507676697\JobAg\JobAg
I then get this error, which doesnāt tell me much about what is going wrong:
[10:06:56]**[Step 1/1]* 2024-01-19 10:06:56,874 [ERROR] dotnet failed for sonarscanner end /d:sonar.token="TOKEN"*
[10:07:00]**[Step 1/1]* Error message: 2024-01-19 10:06:56,874 [ERROR] dotnet failed for sonarscanner end /d:sonar.token="TOKEN"*
The setup has worked for other projects, but here we get this error. There is no background task created in SonarCloud, so it does not seem like the end step has any success at all.
The sonar cloud project key, token and branch are retrieved from a configuration file, which uses the same paths as those used for the build. I have made sure that they use the same paths and that sonarscanner is used in the right directory.