How to configure github actions yml file to only scan a certain project (directory) in a monorepo?

I have created different sonarCloud projects from a monorepo and used the .yml file generated by the sonarCloud itself to configure analysis for .Net via GitHub actions. Even though different jobs have been created for different projects within the mono repo. All the jobs seems to be scanning the whole repo

I was wondering if there is a certain parameter to add to the .ylm file to indicate the directory to be scanned for each project and only to trigger a project analysis when there is code change in the corresponding directory.

sample github action workflow yml configuration.txt (3.5 KB)

Hey there.

It looks like in both runs, you simply run dotnet build instead of pointing to a specific project/solution (dotnet build Project1.csproj). Because of that, it makes sense that in this case, your entire repo is built.

My first reccomendation would be that you only build with dotnet build what you intend to be included in the SonarQube project you reference in the “begin” step of the Scanner for .NET (dotnet-sonarscanner begin /k:"Project1")

1 Like

Thank you Colin for replying to my issue. Another question : should I maybe provide relative path to Project1 after dotnet build ? I made the suggested changes and got the following error

sample github action workflow yml configuration.txt (3.5 KB)

To be clear, I don’t know your project structure or what your projects are named. I was just giving an example. You’ll need a successful dotnet bulid command pointing to your specific project.