Monorepo with .NET

I am having issues setting up a mono repo with dotnet and nextjs using BitBucket pipelines.

I have the following folder structure:

  • frontend
  • backend

I am using the BitBucket pipe for the frontend folder and it works well. However, I am struggling to setup the backend. Since the pipe is not an option there, I am using SonarScanner for MSBuild.

Here is the script I am running:

  - mkdir -p /usr/share/man/man1 /usr/share/man/man2 && apt-get update && apt-get install -y --no-install-recommends openjdk-11-jre;
  - export PATH="$PATH:/root/.dotnet/tools"
  - dotnet tool install --global dotnet-sonarscanner
  - dotnet sonarscanner begin /key:"$SONAR_PROJECT_BACKEND" /organization:"$SONAR_ORGANIZATION" /name:sonar.projectName="Spodio Chat (Backend)" /version:"$BITBUCKET_COMMIT" /"$SONAR_URL" /d:sonar.login="$SONAR_TOKEN" /d:sonar.projectBaseDir=backend /d:sonar.cs.opencover.reportsPaths="TestResults/**/coverage.opencover.xml" /d:sonar.sources=src /d:sonar.tests=tests
  - dotnet restore backend
  - dotnet build backend --no-restore --configuration Release
  - dotnet test backend --no-build --configuration Release --test-adapter-path:backend --logger:"junit;LogFilePath=./test-reports/build_${BITBUCKET_BUILD_NUMBER}/junit.xml" --collect:"XPlat Code Coverage" --settings backend/coverlet.runsettings --results-directory TestResults
  - dotnet sonarscanner end /d:sonar.login="$SONAR_TOKEN"

This is however failing on the post-processing step with:

12:10:17.019  The project base directory doesn't exist.
12:10:17.019  Generation of the sonar-properties file failed. Unable to complete the analysis.
12:10:17.022  Post-processing failed. Exit code: 1

Not sure what I am doing wrong, but I am struggling for a while now. Do you have any suggestions I could try?

Welcome to the community!

Can you please send the full output of the dotnet sonarscanner end command? If you prefer to share that in a private thread instead of publicly, let me know and I can open one.

@dstoyanoff, I’ve had a chat offline with @janos and there’s something we’d like you try first.

The Scanner for .NET will calculate the values for sonar.sources and sonar.tests properties automatically, based on the files that are included in the build.

Also, you would not normally need to set the sonar.projectBaseDir property since that will be calculated too.

We suggest you try removing those three properties and see what results you get.

1 Like