需要有关使用 Visual Studio 17 将 QT 桌面应用程序打包为 AppX 格式的指导

Need guidance on packaging QT Desktop Application into AppX format using Visual Studio 17

本文关键字:应用程序 AppX 格式 桌面 QT Visual Studio      更新时间:2023-10-16

我正在尝试为我的QT GUI应用程序创建一个appx/appxupload包,以便可以将其发布到Windows应用商店。以下是我生成 appx 包所遵循的步骤列表:

  1. 使用我的 QT .pro 文件生成一个 Visual Studio 项目文件,方法是在包含我的 .pro 文件的目录中使用qmake -tp vc命令。我在QT中使用了x86 msvc-2017套件
  2. 使用Visual Studio 2017,版本15.9.10打开.vcproj文件,并生成项目以检查是否有任何错误。
  3. 将一个新项目Windows 应用程序打包项目 (Visual C++(添加到同一个 Visual Studio 解决方案中。
  4. 添加了我的 QT 项目(现在转换为 Visual Studio 项目(作为对新打包项目中应用程序的引用
  5. 在设计器模式下添加了所有视觉对象资产、应用名称和其他配置设置,然后生成项目
  6. 打包应用程序以上载到 Windows 应用商店

当我尝试安装和运行该应用程序时,我收到一条错误消息:此应用程序无法启动,因为它无法在"中找到或加载Qt平台插件"windows"。所有QT插件都存在于安装文件夹中,但是我的应用程序exe文件存在于安装目录中的另一个文件夹中,例如AppName\AppName.exe。如果我将 AppName.exe复制到 AppName 文件夹外部并运行,则应用程序运行正常。

我浏览了各种 xml 文件,在应用程序部分下看到可执行文件 = "AppName\AppName.exe"而不是可执行文件 = AppName.exe我相信有一个配置设置,可以在其中配置应用程序目标路径。如果 exe 文件与所有其他 QT dll 的文件处于同一级别,则应用程序将正常运行而不会出错。

有人可以帮助解决这个问题吗?

谢谢

Visual Studio 生成的Package.appxmanifest

<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap mp rescap">
<Identity Name="CybernetyxTechnikPvt.Ltd.AirMindThinker" Publisher="CN=FD00F14F-4E0A-4328-8B66-60A5777EDBFE" Version="1.0.24.0" />
<Properties>
<DisplayName>AirMind Thinker</DisplayName>
<PublisherDisplayName>Cybernetyx Technik Pvt. Ltd.</PublisherDisplayName>
<Logo>ImagesStoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$">
<uap:VisualElements DisplayName="AirMind Thinker" Description="AirMind Thinker Application" BackgroundColor="transparent" Square150x150Logo="ImagesSquare150x150Logo.png" Square44x44Logo="ImagesSquare44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="ImagesWide310x150Logo.png" Square310x310Logo="ImagesLargeTile.png" Square71x71Logo="ImagesSmallTile.png">
</uap:DefaultTile>
<uap:SplashScreen Image="ImagesSplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>

这是在输出文件夹 (bin/x86/Release/( 中生成的AppxManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap mp rescap build" xmlns:build="http://schemas.microsoft.com/developer/appx/2015/build">
<!--
THIS PACKAGE MANIFEST FILE IS GENERATED BY THE BUILD PROCESS.
Changes to this file will be lost when it is regenerated. To correct errors in this file, edit the source .appxmanifest file.
For more information on package manifest files, see http://go.microsoft.com/fwlink/?LinkID=241727
-->
<Identity Name="CybernetyxTechnikPvt.Ltd.AirMindThinker" Publisher="CN=FD00F14F-4E0A-4328-8B66-60A5777EDBFE" Version="1.0.24.0" ProcessorArchitecture="x86" />
<Properties>
<DisplayName>AirMind Thinker</DisplayName>
<PublisherDisplayName>Cybernetyx Technik Pvt. Ltd.</PublisherDisplayName>
<Logo>ImagesStoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.14393.0" MaxVersionTested="10.0.17763.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.17763.0" />
<PackageDependency Name="Microsoft.VCLibs.140.00.UWPDesktop" MinVersion="14.0.26905.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
</Dependencies>
<Resources>
<Resource Language="EN-US" />
</Resources>
<Applications>
<Application Id="App" Executable="AirMindThinkerAirMindThinker.exe" EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements DisplayName="AirMind Thinker" Description="AirMind Thinker Application" BackgroundColor="transparent" Square150x150Logo="ImagesSquare150x150Logo.png" Square44x44Logo="ImagesSquare44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="ImagesWide310x150Logo.png" Square310x310Logo="ImagesLargeTile.png" Square71x71Logo="ImagesSmallTile.png"></uap:DefaultTile>
<uap:SplashScreen Image="ImagesSplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
</Capabilities>
<build:Metadata>
<build:Item Name="Microsoft.Build.DesktopBridge.Tasks.dll" Version="4.6.30319.200" />
<build:Item Name="TargetFrameworkMoniker" Value=".NETCore,Version=v5.0" />
<build:Item Name="VisualStudio" Version="15.0" />
<build:Item Name="VisualStudioEdition" Value="Microsoft Visual Studio Community 2017" />
<build:Item Name="OperatingSystem" Version="10.0.18362.1 (WinBuild.160101.0800)" />
<build:Item Name="Microsoft.Build.AppxPackage.dll" Version="15.0.28307.104" />
<build:Item Name="ProjectGUID" Value="e995a5ab-e99d-4e1c-864d-a5fbbfc73ceb" />
<build:Item Name="MakePri.exe" Version="10.0.17763.132 (WinBuild.160101.0800)" />
</build:Metadata>
</Package>