I am using the .Net GitHub actions tutorial provided in the SonarQube Cloud UI.
name: SonarQube
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build and analyze
runs-on: windows-latest
steps:
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu' # Alternative distribution options are available.
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Cache SonarQube Cloud packages
uses: actions/cache@v4
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarQube Cloud scanner
id: cache-sonar-scanner
uses: actions/cache@v4
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarQube Cloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool install --global dotnet-sonarscanner
- name: Build and analyze
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
dotnet-sonarscanner begin /k:"project_name" /o:"org_name" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
dotnet build file.sln --no-incremental -v:d
dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
I am getting below error. I have tried -t:Rebuild as per other post but still getting the error.
Done executing task "RestoreTask" -- FAILED.
1 Error(s)
**1. The project has not been built - the project must be built in between the begin and end steps.**
** 2. An unsupported version of MSBuild has been used to build the project. Supported versions: MSBuild 16 and higher.**
** 3. The begin, build and end steps have not all been launched from the same folder.**
** 4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln).**
02:20:06.425 Post-processing failed. Exit code: 1
Error: Process completed with exit code 1.