I’m trying to integrate sonarcloud with my github project and i get this error: error NETSDK1045: The current .NET SDK does not support targeting .NET 6.0. Either target .NET 5.0 or lower, or use a version of the .NET SDK that supports .NET 6.0.
. I found the fix for this issue, but its for Azure DevOps: - task: UseDotNet@2 displayName: 'Use .NET Core sdk' inputs: packageType: 'sdk' version: '6.0.x' includePreviewVersions: true
But I’m using .github/workflows/build.yml
file, so I don’t know how to adjust to it
Hey there.
What does your .github/workflows/build.yml file look like today?
Hi @Colin,
This is my build.yml
file :
on:
# Trigger analysis when pushing in main or pull requests, and when creating
# a pull request.
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
name: Sonar Scan
jobs:
sonarcloud:
runs-on: windows-latest
steps:
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.11
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v1
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"PaladiAlexandru_Classification-of-IrisFlower" /o:"paladialexandru" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
dotnet build WebAppIris.sln
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
You probably need to use actions/setup-dotnet. I anticipate this isn’t really a SonarCloud / Scanner for .NET issue – I would suggest you focus on making sure you have a working beginning-to-end build of your project using GitHub actions, and then add back in the SonarCloud bits.
I did the same integration steps but on a .NET 5 version project. And worked perfectly! I’ll change my entire project to .NET 5, so you can close this thread. Thank you for your help!
Hey there.
Nice to hear you’re no longer blocked, by all means you should be able to use .NET 6 all the way through your build with a project targeting .NET 6… it just needs to be configured using the action I linked earlier. .NET 5 is EOL in a few months while .NET 6 is an LTS version.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.