I’m trying to use SonarCloud’s Github Actions within a CI to build and test a Windows based C++ application. The issue I’m facing is that regardless of how I update the Run build wrapper
step, the job failed with the below error:
[SONARSOURCE BUILD-WRAPPER] failed to execute msbuild.exe .MySolution.sln /t:Rebuild: The system cannot find the file specified.
My existing config is below. I have listed the directly using gci
and ls
in the job and confirmed the file is present. I have changed into the correct directory, renamed files, used relative paths and created ${{ env.BUILD_WRAPPER_OUT_DIR }}
, just in case. Every time I end up with the same error.
Some examples of what I’ve tried:
build-wrapper-win-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} msbuild.exe MySolution.sln
build-wrapper-win-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} msbuild .MySolution.sln
build-wrapper-win-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} MSBuild.exe .MySolution.sln
I assumed msbuild
was looking for the .sln
file, but that doesn’t seem correct. It’s just not clear what file isn’t being found and causing the subsequent error. Any ideas for corrections much appreciated!
name: SonarCloud
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build and analyze
runs-on: windows-latest
env:
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@v3
- name: Run build-wrapper
run: |
build-wrapper-win-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} msbuild .MySolution.sln /t:Rebuild
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner --define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"
Job logs
Run build-wrapper-win-x86-64 --out-dir build_wrapper_output_directory msbuild.exe .MySolution.sln /t:Rebuild
build-wrapper-win-x86-64 --out-dir build_wrapper_output_directory msbuild.exe .MySolution.sln /t:Rebuild
shell: C:Program FilesPowerShell7pwsh.EXE -command ". '{0}'"
env:
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory
SONAR_HOST_URL: https://sonarcloud.io
[SONARSOURCE BUILD-WRAPPER] failed to execute msbuild .MySolution.sln /t:Rebuild: The system cannot find the file specified.
Error: Process completed with exit code 1.