Is it possible to integrate Qt Add-in/Plugin into Visual Studio 2022 within a GitHub Actions workflow?
-
I'm trying to set up a GitHub Actions workflow to build a project that requires Visual Studio 2022 and the Qt Add-in/Plugin in visual studio 2022. Below is a snippet of my workflow configuration. I'm encountering issues with configuring the Qt version and path. Integrating the Qt Add-in into Visual Studio 2022.
My workflow steps include:
Verifying Visual Studio 2022 installation.
Downloading and verifying the Qt VS Add-in.
Installing the Qt VS Add-in using VSIXInstaller.exe.
Configuring the Qt version in the expected paths.
Here is a relevant part of my YAML configuration:- name: Verify Visual Studio 2022 installation run: | $vswherePath = "${env:ProgramFiles(x86)}\\Microsoft Visual Studio\\Installer\\vswhere.exe" if (-Not (Test-Path $vswherePath)) { Write-Error "vswhere.exe not found. Visual Studio 2022 might not be installed." exit 1 } $vsInstallPath = & $vswherePath -latest -version "[17.0,18.0)" -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath Write-Output "VS_INSTALL_PATH=$vsInstallPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 - name: Download Qt VS Add-in run: | $url = "https://mirror.netcologne.de/qtproject/development_releases/vsaddin/3.0.2/qt-vsaddin-msvc2022-3.0.2.vsix" $output = "qt-vsaddin-msvc2022-3.0.2.vsix" Invoke-WebRequest -Uri $url -OutFile $output - name: Verify SHA-256 Hash run: | $expectedHash = "b1eba080495505638e2431e85ffa4108ee3b688595cc4657f1b80e30712c2f23" $fileHash = Get-FileHash -Path "qt-vsaddin-msvc2022-3.0.2.vsix" -Algorithm SHA256 if ($fileHash.Hash -ne $expectedHash) { throw "Hash mismatch: $($fileHash.Hash)" - name: Find VSIXInstaller run: | $vswherePath = "${env:ProgramFiles(x86)}\\Microsoft Visual Studio\\Installer\\vswhere.exe" $vsInstallPath = & $vswherePath -latest -version "[17.0,18.0)" -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath $vsixInstallerPath = Join-Path -Path $vsInstallPath -ChildPath "Common7\\IDE\\VSIXInstaller.exe" if (-Not (Test-Path $vsixInstallerPath)) { Write-Error "VSIXInstaller.exe not found." exit 1 } Write-Output "VSIX_INSTALLER_PATH=$vsixInstallerPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 - name: Install Qt VS Add-in run: | $vsixInstallerPath = $env:VSIX_INSTALLER_PATH Start-Process -FilePath $vsixInstallerPath -ArgumentList "/q", "qt-vsaddin-msvc2022-3.0.2.vsix" -NoNewWindow -Wait - name: Configure Qt Version env: QT_PATH: ${{ github.workspace }}\\ThirdParty\\Qt\\6.6.1\\msvc2019_64 run: | $qtVersionName = "6.6.1" $qtPath = "${env:QT_PATH}" $configPaths = @( "$env:APPDATA\\QtProject\\qtcreator\\qtversion.xml", "$env:LOCALAPPDATA\\QtProject\\qtcreator\\qtversion.xml" ) $qmakePath = Join-Path $qtPath "bin\\qmake.exe" $configFound = $false foreach ($configPath in $configPaths) { if (Test-Path $configPath) { $configFound = $true [xml]$qtConfig = Get-Content $configPath if (-Not $qtConfig.qtcreator.qtversions.qtversion) { $qtConfig.qtcreator.AppendChild($qtConfig.CreateElement("qtversions")) | Out-Null } $newVersion = $qtConfig.CreateElement("qtversion") $newVersion.SetAttribute("Id", "qt." + $qtVersionName) $newVersion.SetAttribute("Name", $qtVersionName) $newVersion.SetAttribute("QMakePath", $qmakePath) $qtConfig.qtcreator.qtversions.AppendChild($newVersion) | Out-Null $qtConfig.Save($configPath) Write-Host "Configured Qt version $qtVersionName with path $qtPath in $configPath" } } if (-Not $configFound) { Write-Error "Qt configuration file not found in expected paths." Write-Host "Expected paths: $($configPaths -join ', ')" Write-Host "Ensure that Qt Creator is installed and has been run at least once to generate configuration files." exit 1
Issues:
-
The script throws an error indicating that the Qt configuration file is not found in the expected paths.
-
I need to ensure Qt is correctly configured in visual studio 2022 and available within the GitHub Actions environment.
Questions:
-
Is it possible to integrate the Qt VS Add-in/Plugin into Visual Studio 2022 in a GitHub Actions workflow?
-
Are there any additional steps required to configure Qt within a CI/CD pipeline using GitHub Actions?
Any advice or example workflows would be greatly appreciated!
-
-
Hi and welcome to devnet,
What project manager are you using ? qmake or CMake ?
You should not need the AddOn to build your application from the command line like is done in a CI/CD. -
Hi SGaist,
Thank you for your response and insights. I appreciate the clarification regarding the necessity of the Qt Add-in/Plugin for command-line builds.
My project currently uses MSBuild for the build process. Given your input, I'll explore whether the add-in is indeed essential for our CI/CD pipeline or if we can streamline our setup.
For additional context, here's the workflow configuration I currently use in my GitHub Actions setup:
name: MSBuild on: push: branches: [ "Demo" ] pull_request: branches: [ "Demo" ] env: DEVENV_PATH: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE QT_PATH: ${{ github.workspace }}\ThirdParty\Qt\6.6.1\msvc2019_64 permissions: contents: read jobs: build: runs-on: windows-latest steps: - name: Check out the main project repository uses: actions/checkout@v4 - name: Check out the third-party repository uses: actions/checkout@v4 - name: Add Visual Studio to PATH uses: microsoft/setup-msbuild@v1.0.2 - name: Install Qt uses: jurplel/install-qt-action@v4 with: version: '6.6.1' host: 'windows' target: 'desktop' arch: 'win64_msvc2019_64' - name: Setup and Execute Build shell: cmd run: | echo "Current directory: %cd%" set DEV_ROOT=%cd%\OT set DEVENV_ROOT_2022=%DEVENV_PATH% set THIRDPARTY_ROOT=%cd%\ThirdParty set QtMsBuild=%cd%\ThirdParty\Qt\6.6.1\msvc2019_64 set PATH=%QtMsBuild%\bin;%PATH% echo "DEV_ROOT=%DEV_ROOT%" echo "DEVENV_ROOT_2022=%DEVENV_ROOT_2022%" echo "THIRDPARTY_ROOT=%THIRDPARTY_ROOT%" echo "Checking if BuildAll.bat exists..." echo "Starting BuildAll.bat..." call %DEV_ROOT%\BuildAll.bat echo "All checks passed." - name: Upload build log summary artifact if: always() uses: actions/upload-artifact@v2 with: name: build-log-Debug path: ${{ github.workspace }}\buildLog.txt
And here's the build.bat file I'm running through the workflow:
@ECHO ON IF "%DEV_ROOT%" == "" ( ECHO Please specify the following environment variables: DEV_ROOT goto PAUSE_END ) IF "%DEVENV_ROOT_2022%" == "" ( ECHO Please specify the following environment variables: DEVENV_ROOT_2022 goto END ) IF "%QtMsBuild%" == "" ( ECHO Please install and set up the "Qt Visual Studio Tools" extension in Visual Studio, since it is required for build. goto END ) REM build "%DEVENV_ROOT_2022%\devenv.exe" "%DEV_ROOT%\project.vcxproj" /Release "Release|x64"
Based on your suggestion, I understand that using the add-in might not be necessary for command-line builds. Could you provide more details or examples on how to configure Qt for MSBuild without relying on the Qt Visual Studio Add-in? Any advice or example workflows would be greatly appreciated!
Thank you again for your help!
-
I haven't use the plugin myself but from my understanding you should have the project already configured for MSBuild and it should be possible to build it from the command line using
MSBuild.exe
.