My objective is to install CppCheck in a Microsoft-Hosted image in Azure Pipelines. I already did this for an Ubuntu image, but CppCheck for Ubuntu is outdated. My pipeline:
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
jobs:
- job: MisraCheck
displayName: Check for Misra Compliance
steps:
- script: |
sudo apt-get install cppcheck
displayName: 'Install cppcheck'
- script: |
cppcheck --error-exitcode=1 --addon=misra.json .
displayName: 'Run cppcheck'
As I am familiar with Linux (and apt-get), it was very easy to set-up this pipeline. But now I have to "translate" this pipeline to use on a Windows image.
CppCheck for Windows is a downloadable .msi file available at this page. The download link is easy to get.
I am aware that I need to use a Windows image in the pipeline, like "windows-2019" or "vs2017-win2016". The main question is how can I replace the apt-get command to get the .msi file from a link and install it?
Thanks!
How to install an .msi program in Azure Pipeline (Windows)
You could use the Powershell task to install the .msi file:
Start-Process $(System.DefaultWorkingDirectory)\cppcheck-2.6-x64-Setup.msi -ArgumentList "/quiet"
Start-Sleep 180 #waiting for installing complete
And you need upload the .msi
to your repo. Or you could use PowerShell scripts to download the .msi
from the URL:
Update:
Invoke-WebRequest https://github.com/danmar/cppcheck/releases/download/2.6/cppcheck-2.6-x64-Setup.msi -OutFile $(System.DefaultWorkingDirectory)\cppcheck-2.6-x64-Setup.msi
Start-Sleep 90 #waiting for downloadig complete