You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During the analysis of a .NET project with SonarScanner, after building the project using .NET 7 through the dotnet CLI, the end step fails with the error:
16:10:24.487 Generating SonarQube project properties file to .\Projects\ProjectRoot\.sonarqube\out\sonar-project.properties
16:10:24.501 Generation of the sonar-properties file failed. Unable to complete the analysis.
Additionally in build step logs:
Sonar: (Project.Net5.csproj) The analysis targets file not found: .\Projects\AnotherProject\.sonarqube\bin\targets\SonarQube.Integration.targets
The dotnet build cannot correctly detect the base path of the project because the MSBuildStartupDirectory property has the wrong value. We use MSBuildStartupDirectory to detect the root folder of the project and create there the .sonarqube directory.
(see here where MSBuildStartupDirectory is used in the sonar-scanner-msbuild repo).
cd Project1
dotnet sonarscanner begin /k:"project-key" /d:sonar.login="token"
dotnet build
dotnet sonarscanner end /d:sonar.login="token"
In the case, this succeeds it means that the MSBuildStartupDirectory was not set yet - so now it should be set to .\Project1.
So to reproduce now you should run also:
cd ..
cd Project2
dotnet sonarscanner begin /k:"project-key" /d:sonar.login="token"
dotnet build
dotnet sonarscanner end /d:sonar.login="token"
If you want to see the values of the MSBuildStartupDirectory in the two projects:
cd Project1
dotnet build /target:DisplayMessages
cd ../Project2
dotnet build /target:DisplayMessages
Expected behavior
SonarScanner.MSBuild.exe end should call sonar-scanner.bat and send the data.
Actual behavior
Analysis fails.
Known workarounds
Build the project through MSBuild with the command:
msbuild /t:rebuild -v:d
This will compile, allowing the end step to finish the analysis.
The text was updated successfully, but these errors were encountered:
mary-georgiou-sonarsource
changed the title
Running build command with .Net 7 cause SonarScanner to fail the analysis
Analysis fails with .NET 7
Oct 26, 2022
According to the discussion in this issue, the problem should be solved after the release of .NET 7.
Meanwhile, a workaround to use the dotnet build CLI command is to set DOTNET_CLI_DO_NOT_USE_MSBUILD_SERVER=1 in the environment variables.
Description
During the analysis of a .NET project with SonarScanner, after building the project using .NET 7 through the dotnet CLI, the end step fails with the error:
Additionally in build step logs:
The dotnet build cannot correctly detect the base path of the project because the
MSBuildStartupDirectory
property has the wrong value. We useMSBuildStartupDirectory
to detect the root folder of the project and create there the.sonarqube
directory.(see here where
MSBuildStartupDirectory
is used in the sonar-scanner-msbuild repo).Repro steps
Clone https://github.com/mary-georgiou-sonarsource/scanner-net7-repro
In the case, this succeeds it means that the
MSBuildStartupDirectory
was not set yet - so now it should be set to.\Project1
.So to reproduce now you should run also:
If you want to see the values of the
MSBuildStartupDirectory
in the two projects:Expected behavior
SonarScanner.MSBuild.exe end should call sonar-scanner.bat and send the data.
Actual behavior
Analysis fails.
Known workarounds
Build the project through MSBuild with the command:
msbuild /t:rebuild -v:d
This will compile, allowing the end step to finish the analysis.
The text was updated successfully, but these errors were encountered: