首页 > 解决方案 > 需要有关使用 Visual Studio 17 将 QT 桌面应用程序打包成 AppX 格式的指导

问题描述

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

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

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

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

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

谢谢

标签: c++qtuwpvisual-studio-2017appx

解决方案


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>Images\StoreLogo.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="Images\Square150x150Logo.png" Square44x44Logo="Images\Square44x44Logo.png">
        <uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" Square310x310Logo="Images\LargeTile.png" Square71x71Logo="Images\SmallTile.png">
        </uap:DefaultTile>
        <uap:SplashScreen Image="Images\SplashScreen.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>Images\StoreLogo.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="AirMindThinker\AirMindThinker.exe" EntryPoint="Windows.FullTrustApplication">
      <uap:VisualElements DisplayName="AirMind Thinker" Description="AirMind Thinker Application" BackgroundColor="transparent" Square150x150Logo="Images\Square150x150Logo.png" Square44x44Logo="Images\Square44x44Logo.png">
        <uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" Square310x310Logo="Images\LargeTile.png" Square71x71Logo="Images\SmallTile.png"></uap:DefaultTile>
        <uap:SplashScreen Image="Images\SplashScreen.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>

推荐阅读