highbyte / sonarscan-dotnet

GitHub Action SonarCloud/SonarQube scanner for .NET 8/7/6/5 and .NET Core applications with pull request decoration support
https://github.com/marketplace/actions/sonarscan-dotnet
MIT License
36 stars 24 forks source link

Specify a project or solution file #5

Closed fergek-ms closed 3 years ago

fergek-ms commented 3 years ago

Hi!

I'm trying to send data to my on premise SonarQube using this sonarscan-dotnet.

I'll add here the content of my .YML file

name: Static analysis code
on: [push]
jobs:
  static-analysis:
    runs-on: ubuntu-latest
    env:
      SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: actions/checkout@v2
      - uses: highbyte/sonarscan-dotnet@1.0
        with:
          sonarProjectKey: prp-be
          sonarProjectName: prp-be
          sonarHostname: https://sonarqube.prdevelopment.net/

When the github action runs I can see on the logs the following error:

MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.

Is there anything you see in my YML file that I have to correct to get this working?

Thanks in advance.

highbyte commented 3 years ago

If your .NET project or solution file isn't located in the repository root, you need to specify the path to it with the dotnetBuildArguments parameter. See example here: https://github.com/highbyte/sonarscan-dotnet#build-subfolder-src-and-include-code-coverage

highbyte commented 3 years ago

Did you manage to get your action working?

renepanke commented 3 years ago

I've got the same issue tho. '.sln' file is localized in the repository root but still doesn't work..

If you want to have a look at the repo see SVYSHE/Jobb

highbyte commented 3 years ago

It seems you'll need to add a step before sonarscan-dotnet step, to checkout the repo. Otherwise the sonarscan-dotnet step doesn't have access to any source code to build/scan.

    steps:
    # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
    - uses: actions/checkout@v2
      with:
        fetch-depth: '0'

    - name: sonarscan-dotnet
      uses: highbyte/sonarscan-dotnet@2.0
      with:
        ...
renepanke commented 3 years ago

I'm relatively new to the github pipelines, so sorry that i ask you, how this additional step would look like..

Well after I read your answer a second time, i finally got, what you wanted to say and the pipeline's running 😂

Thanks for the quick help! My problems are solved so from my point of view you can close this issue :)

highbyte commented 3 years ago

@SVYSHE No problem :)

I'm closing this issue. @fergek-ms if you still have an issue, feel free to open another one with details on how your repo looks like (folder structure for .sln/.csproj files).