# windeployqt-to-wix # # Windeployqt-to-wix - Convert the output of windeployqt to an equivalent set of # Wix file and component statements. # # Copyright 2016 Michael Mann # # Wireshark - Network traffic analyzer # By Gerald Combs # Copyright 1998 Gerald Combs # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #requires -version 2 <# .SYNOPSIS Creates Wix components required for Qt packaging. .DESCRIPTION This script creates an Wix-compatible include file based on the following Qt versions: - 5.3 and later: A list of DLLs and directories based on the output of the "windeployqt" utility. Windeployqt lists the DLLs required to run a Qt application. (The initial version that shipped with Qt 5.2 is unusable.) - 5.2 and earlier: A hard-coded list of Qt DLLs and directories appropriate for earlier Qt versions. - None: A dummy file. If building with Qt, QMake must be in your PATH. .PARAMETER Executable The path to a Qt application. It will be examined for dependent DLLs. .PARAMETER FilePath Output filename. .INPUTS -Executable Path to the Qt application. -FilePath Output Wix include file. .OUTPUTS Wix file required to package supporting DLLs. .EXAMPLE C:\PS> .\windeployqt-to-wix.ps1 windeployqt.exe ..\..\staging\wireshark.exe qt-dll-manifest.wxs #> Param( [Parameter(Mandatory=$true, Position=0)] [String] $Executable, [Parameter(Position=1)] [String] $FilePath = "qt-dll-manifest.wxs" ) try { $qtVersion = [version](qmake -query QT_VERSION) $wixComponents = " " $wixComponents += @(" ") if ($qtVersion -ge "5.3") { # Qt 5.3 or later. Windeployqt is present and works $wdqtList = windeployqt ` --release ` --no-compiler-runtime ` --list relative ` $Executable $dllPath = Split-Path -Parent $Executable $dllList = " " $dirList = "" $currentDir = "" $startDirList = " " $endDirList = " " $currentDirList = $startDirList $componentGroup = " " foreach ($entry in $wdqtList) { $dir = Split-Path -Parent $entry if ($dir) { if ($dir -ne $currentDir) { if ($currentDir -ne "") { # for everything but first directory found $currentDirList += $endDirList # Previous directory complete, add to list $dirList += $currentDirList } else { } $currentDirList = $startDirList + " " $currentDir = $dir } $wix_name = $entry -replace "[\\|\.]", "_" $currentDirList += " " $componentGroup += " " } else { $dllList += " " $componentGroup += " " } } #finish up the last directory $currentDirList += $endDirList $dirList += $currentDirList $dllList += " " $componentGroup += " " $wixComponents += $dllList + $dirList + $componentGroup } elseif ($qtVersion -ge "5.0") { # Qt 5.0 - 5.2. Windeployqt is buggy or not present $wixComponents += @" "@ } else { # Assume Qt 4 $wixComponents += @" "@ } $wixComponents += @" "@ } catch { $wixComponents = " " } Set-Content $FilePath @" "@ Add-Content $FilePath $wixComponents