Hi, please give me the full instruction to implement the task to create the build wrapper for Azure DevOps environment. As I apply it to the Microsoft hosted agent pool, I can’t install it in the pool so I am considering to check-in it with the repo. This is the 1st time i config a C project
As we use the Linux server, I assume that I will need the Build wrapper for Linux I find in here: https://sonarcloud.io/documentation/analysis/languages/cfamily/. I already define the sonar.sources property and I also have a makefile inside the repositories.
Many thanks
You can download the wrapper during build. I did this on our on SonarQube installation. With sonar.cfamily.build-wrapper-output=$(SonarOutDir)
I use the two tasks:
# Make Build Wrapper available on the build agent
- task: petergroenewegen.PeterGroenewegen-Xpirit-Vsts-Build-InlinePowershell.Xpirit-Vsts-Build-InlinePowershell.InlinePowershell@1
displayName: 'Make Build Wrapper available on the build agent'
condition: and(succeeded(), eq(variables['AnalyseSolution'], true))
inputs:
Script: |
Invoke-WebRequest -Uri '$(SonarQubeUrl)static/cpp/build-wrapper-win-x86.zip' -OutFile '$(build.artifactstagingdirectory)/build-wrapper.zip'
Expand-Archive -Path '$(build.artifactstagingdirectory)/build-wrapper.zip' -DestinationPath $(build.artifactstagingdirectory)/
# Build C++ solution
- task: petergroenewegen.PeterGroenewegen-Xpirit-Vsts-Build-InlinePowershell.Xpirit-Vsts-Build-InlinePowershell.InlinePowershell@1
displayName: 'Build solution Src/ToolStudio.sln with build wrapper'
inputs:
Script: |
New-Item -Path $(SonarOutDir) -ItemType directory -Force
Set-Location $(SrcDir)
$(build_wrapper) --out-dir $(SonarOutDir) "$(msbuildPath)/MSBuild.exe" $(SrcDir)/MySolution.sln /t:Rebuild /nologo /nr:false /t:"Clean" /p:FullRelease=true /p:platform=$(BuildPlatform) /p:configuration=$(BuildConfiguration) /p:VisualStudioVersion="16.0" /m
You should use the cache - that speed up my time of analyzes roughly by factor 10.
3 Likes
Thank you for your solution. It works for me when I need to download the buil-wrapper. However, for the Build step, as we dont use the MSBuild but the makefile so i am looking for another solution that solve this problem.