I am trying to analyze my dotnet framework 4.6.1 project using sonar cloud using github actions but unable to do so it gives the below error while making the build
Run .\.sonar\scanner\dotnet-sonarscanner begin /k:"Imobisoft_Test" /o:"imobisoft" /d:sonar.login="***" /d:sonar.host.url="[https://sonarcloud.io](https://sonarcloud.io/)"
[12](https://github.com/Imobisoft/Test/runs/5158235404?check_suite_focus=true#step:7:12)SonarScanner for MSBuild 5.5.2
[13](https://github.com/Imobisoft/Test/runs/5158235404?check_suite_focus=true#step:7:13)Using the .NET Core version of the Scanner for MSBuild
[14](https://github.com/Imobisoft/Test/runs/5158235404?check_suite_focus=true#step:7:14)Pre-processing started.
[15](https://github.com/Imobisoft/Test/runs/5158235404?check_suite_focus=true#step:7:15)Preparing working directories...
[16](https://github.com/Imobisoft/Test/runs/5158235404?check_suite_focus=true#step:7:16)15:26:50.986 Updating build integration targets...
[17](https://github.com/Imobisoft/Test/runs/5158235404?check_suite_focus=true#step:7:17)15:26:51.84 Fetching analysis configuration settings...
[18](https://github.com/Imobisoft/Test/runs/5158235404?check_suite_focus=true#step:7:18)15:26:53.1 Provisioning analyzer assemblies for cs...
[19](https://github.com/Imobisoft/Test/runs/5158235404?check_suite_focus=true#step:7:19)15:26:53.101 Installing required Roslyn analyzers...
[20](https://github.com/Imobisoft/Test/runs/5158235404?check_suite_focus=true#step:7:20)15:26:54.886 Provisioning analyzer assemblies for vbnet...
[21](https://github.com/Imobisoft/Test/runs/5158235404?check_suite_focus=true#step:7:21)15:26:54.886 Installing required Roslyn analyzers...
[22](https://github.com/Imobisoft/Test/runs/5158235404?check_suite_focus=true#step:7:22)15:26:54.917 Pre-processing succeeded.
[23](https://github.com/Imobisoft/Test/runs/5158235404?check_suite_focus=true#step:7:23)MSBuild.exe : The term 'MSBuild.exe' is not recognized as the name of a cmdlet, function, script file, or operable
[24](https://github.com/Imobisoft/Test/runs/5158235404?check_suite_focus=true#step:7:24)program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
[25](https://github.com/Imobisoft/Test/runs/5158235404?check_suite_focus=true#step:7:25)At D:\a\_temp\aa8a7607-7528-4d9a-859c-8344c5ab2b21.ps1:3 char:1
[26](https://github.com/Imobisoft/Test/runs/5158235404?check_suite_focus=true#step:7:26)+ MSBuild.exe CopdPredict-V3-Backend-US\COPDSolution.sln
[27](https://github.com/Imobisoft/Test/runs/5158235404?check_suite_focus=true#step:7:27)+ ~~~~~~~~~~~
[28](https://github.com/Imobisoft/Test/runs/5158235404?check_suite_focus=true#step:7:28) + CategoryInfo : ObjectNotFound: (MSBuild.exe:String) [], ParentContainsErrorRecordException
[29](https://github.com/Imobisoft/Test/runs/5158235404?check_suite_focus=true#step:7:29) + FullyQualifiedErrorId : CommandNotFoundException
I have used the below build command
name: Build
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
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:"Imobisoft_Test" /o:"imobisoft" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
MSBuild.exe Test\TestSolution.sln
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
Thank you for the response Ann, Can you please help me with where should I provide this path and how can I get it. And also what will be the format of the path
Thank you for the response. I was able to fix that error but I am still facing issues while analyzing. Please find the details below
name: Build
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
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:"Imobisoft_CopdPredict-V3-Backend-US" /o:"imobisoft" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
cd "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\"
.\MSBuild.exe COPDWebAPI/COPDWebAPI.csproj --configuration Release --no-restore
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
It is giving the below error while build and analyze
Run .\.sonar\scanner\dotnet-sonarscanner begin /k:"Imobisoft_CopdPredict-V3-Backend-US" /o:"imobisoft" /d:sonar.login="***" /d:sonar.host.url="[https://sonarcloud.io](https://sonarcloud.io/)"
[2](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:2) .\.sonar\scanner\dotnet-sonarscanner begin /k:"Imobisoft_CopdPredict-V3-Backend-US" /o:"imobisoft" /d:sonar.login="***" /d:sonar.host.url="[https://sonarcloud.io](https://sonarcloud.io/)"
[3](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:3) cd "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\"
[4](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:4) .\MSBuild.exe COPDWebAPI/COPDWebAPI.csproj --configuration Release --no-restore
[5](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:5) .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="***"
[6](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:6) shell: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.EXE -command ". '{0}'"
[7](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:7) env:
[8](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:8) JAVA_HOME_11.0.14_x64: C:\hostedtoolcache\windows\jdk\11.0.14\x64
[9](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:9) JAVA_HOME: C:\hostedtoolcache\windows\jdk\11.0.14\x64
[10](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:10) JAVA_HOME_11_0_14_X64: C:\hostedtoolcache\windows\jdk\11.0.14\x64
[11](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:11) GITHUB_TOKEN: ***
[12](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:12) SONAR_TOKEN: ***
[13](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:13)SonarScanner for MSBuild 5.5.3
[14](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:14)Using the .NET Core version of the Scanner for MSBuild
[15](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:15)Pre-processing started.
[16](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:16)Preparing working directories...
[17](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:17)09:25:16.479 Updating build integration targets...
[18](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:18)09:25:17.04 Fetching analysis configuration settings...
[19](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:19)09:25:17.899 Provisioning analyzer assemblies for cs...
[20](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:20)09:25:17.9 Installing required Roslyn analyzers...
[21](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:21)09:25:18.946 Provisioning analyzer assemblies for vbnet...
[22](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:22)09:25:18.946 Installing required Roslyn analyzers...
[23](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:23)09:25:18.99 Pre-processing succeeded.
[24](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:24)Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET Framework
[25](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:25)Copyright (C) Microsoft Corporation. All rights reserved.
[26](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:26)
[27](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:27)MSBUILD : error MSB1001: Unknown switch.
[28](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:28)Switch: --configuration
[29](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:29)
[30](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:30)For switch syntax, type "MSBuild -help"
[31](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:31).\.sonar\scanner\dotnet-sonarscanner : The term '.\.sonar\scanner\dotnet-sonarscanner' is not recognized as the name
[32](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:32)of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,
[33](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:33)verify that the path is correct and try again.
[34](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:34)At D:\a\_temp\39b34978-5c2e-4630-84c0-3f194c10ff4c.ps1:5 char:1
[35](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:35)+ .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="53cacfc7c983 ...
[36](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:36)+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[37](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:37) + CategoryInfo : ObjectNotFound: (.\.sonar\scanner\dotnet-sonarscanner:String) [], ParentContainsErrorRec
[38](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:38) ordException
[39](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:39) + FullyQualifiedErrorId : CommandNotFoundException
[40](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:40)
[41](https://github.com/Imobisoft/CopdPredict-V3-Backend-US/runs/5213809972?check_suite_focus=true#step:7:41)Error: Process completed with exit code 1.
I am sorry but actually, I am still facing the issue with MSBuild. Earlier I was unable to find the MsBuild on the virtual machine now I am able to find it but unable to build that’s why I replied to the same thread. going forwards I will create new threads for new issues.
I read the log but couldn’t understand it I searched for this error
MSBUILD: error MSB1001: Unknown switch.
but couldn’t find any proper solutions to solve it.