winapi - 如何在 AppxManifest.xml 文件中为使用 Desktop Bridge 转换的 Win32 应用程序正确构建 UWP 应用程序图标(Project Centennial)

标签 winapi uwp windows-10 desktop-bridge

我正在尝试使用 Project Centennial 转换器(即桌面桥)将我的 Win32 应用程序转换为 UWP 应用程序。

应用转换后,我需要调整AppxManifest.xml文件以确保:

  • 所有图标格式均已正确配置。

  • 我为英语(美国)、德语、法语和俄语正确指定了应用资源。

所以我关注了this Windows 10 icon guide并创建了以下 .png 图像,这些图像全部放入 Assets 文件夹中。我得到了这些:

enter image description here

我的 AppxManifest.xml 结构如下:

<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap2="http://schemas.microsoft.com/appx/manifest/uap/windows10/2" xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10">
  <Identity Name="MyApp.Name" ProcessorArchitecture="x86" Publisher="CN=My Name, O=My Name, STREET=&quot;Street Address&quot;, L=City, S=State, PostalCode=12345, C=US" Version="1.2.3.4" />
  <Properties>
    <DisplayName>MyApp.Name</DisplayName>
    <PublisherDisplayName>PublisherName</PublisherDisplayName>
    <Logo>Assets\StoreLogo-50x50.png</Logo>
  </Properties>
  <Resources>
    <Resource Language="en-us" />
    <Resource Language="de-DE" />
    <Resource Language="fr-FR" />
    <Resource Language="ru-RU" />
  </Resources>
  <Dependencies>
    <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14342.0" MaxVersionTested="10.0.14342.0" />
  </Dependencies>
  <Capabilities>
    <rescap:Capability Name="runFullTrust" />
  </Capabilities>
  <Applications>
    <Application Id="MyApp.Name" Executable="VFS\Users\ContainerAdministrator\AppData\Local\PublisherName\App Name\RunFile.exe" EntryPoint="Windows.FullTrustApplication">
      <uap:VisualElements DisplayName="My App Name" Description="My app does this ... and this ..." 
                          BackgroundColor="#aabbcc" 
                          Square71x71Logo="Assets\AppNameSmallTile.png"
                          Square150x150Logo="Assets\AppNameMedTile.png"
                          Square310x150Logo="Assets\AppNameWideTile.png"
                          Square310x310Logo="Assets\AppNameLargeTile.png"
                          Square44x44Logo="Assets\AppNameAppList.png"
                          >
        <uap:DefaultTile>
          <uap:ShowNameOnTiles>
            <uap:ShowOn Tile="square150x150Logo" />
            <uap:ShowOn Tile="Square310x150Logo" />
            <uap:ShowOn Tile="Square310x310Logo" />
          </uap:ShowNameOnTiles>
        </uap:DefaultTile>
      </uap:VisualElements>
      <Extensions />
    </Application>
  </Applications>
</Package>

那么有人可以回答这些问题吗:

  1. 我对指定正确大小和缩放比例的图标有些困惑。我做对了吗?

  2. 是否还需要为 Assets\StoreLogo-50x50.png 图标指定缩放比例?

  3. 最后,我是否正确指定了 4 种不同语言的资源?

编辑:在等待期间,我尝试使用我展示的 Assets 编译上面的 AppxManifest.xml。但是 makeappx.exe 工具给我以下错误:

MakeAppx : error: Error info: error C00CE015: App manifest validation error: The app manifest must be valid as per schema: Line 22, Column 27, Reason: The attribute 'Square71x71Logo' on the element '{http://schemas.microsoft.com/appx/manifest/uap/windows10}VisualElements' is not defined in the DTD/Schema.

它显然不喜欢以下图标尺寸:

Square71x71Logo
Square310x150Logo
Square310x310Logo

但是即使我从 AppxManifest.xml 中删除了上面的图标大小,当我尝试使用以下命令打包它时:

"C:\Program Files (x86)\Windows Kits\10\bin\x64\makeappx.exe" pack /d "path-to-folder-to-pack" /p "path-to\MyAppxPackage.appx"

关于为缩放命名 Assets ,我收到以下错误:

MakeAppx : error: Manifest validation error: Line 22, Column 27, Reason: The file name "Assets\AppNameMedTile.png" declared for element "[local-name()='Applications']/[local-name()='Application']/[local-name()='VisualElements']" doesn't exist in the package. If this file has multiple variations or resource versions for language, scale, contrast, etc., use the /l command line option to disable this validation. MakeAppx : error: Manifest validation error: Line 23, Column 27, Reason: The file name "Assets\AppNameAppList.png" declared for element "[local-name()='Applications']/[local-name()='Application']/[local-name()='VisualElements']" doesn't exist in the package. If this file has multiple variations or resource versions for language, scale, contrast, etc., use the /l command line option to disable this validation. MakeAppx : error: Package creation failed. MakeAppx : error: 0x80080204 - The specified package format is not valid: The package manifest is not valid.

使用建议的 /l 命令:

"C:\Program Files (x86)\Windows Kits\10\bin\x64\makeappx.exe" pack /l /d "path-to-folder-to-pack" /p "path-to\MyAppxPackage.appx"

构建带有大量警告的包。但是后来我安装的时候,里面的图标好像都是空白的。

一定是我遗漏了什么?

最佳答案

我看到两个主要问题:您在错误的位置定义了图 block 图像,并且您根本没有谈论 resources.pri 文件。

UAP 架构相当复杂,但也有合理的文档记录,因此请确保您遵守其要求。特别是 uap:VisualElements element只有图像属性 Square150x150LogoSquare44x44Logo。如果你想定义其他尺寸,它们会进入 child 的属性 uap:DefaultTile element .请注意,您的 uap:ShowOn elements'属性包含不正确的 Square310x150Logo,应该改为 wide310x150Logo

一旦你解决了这个问题,makeappx 应该会成功使用你的原始命令行,即没有额外的 /l 参数。然而,这不足以让您的备用 DPI 图像显示出来。为此,您需要创建一个 resources.pri 文件。您可以手动执行此操作,方法是使用 makepri.exe 创建模板 priconfig.xml,更新它,然后再次调用 makepri 以从中构建 resources.pri。

或者,使用可以为您创建带有 resources.pri 的应用包的工具(例如 Visual Studio),然后提取 resources.pri 并将其添加到您的包中。只需确保您在包中使用的位置与工具创建的包中的位置匹配,因为相对路径存储在 resources.pri 文件中。 (作为奖励,您可以查看它创建的 AppxManifest.xml,以验证第一部分中的结构是否正确。请不要忘记,使用桌面桥的应用程序将具有 Visual Studio 不会提供的其他命名空间和功能。不提供。)

关于winapi - 如何在 AppxManifest.xml 文件中为使用 Desktop Bridge 转换的 Win32 应用程序正确构建 UWP 应用程序图标(Project Centennial),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39910625/

相关文章:

r - 不是内部或外部命令,也不是可运行的程序或批处理文件。 gcloud 调用失败

c++ - 如何制作 Web 浏览器工具栏?

使用 Http Post 的 C Wininet 文件上传

c# - UWP 新应用程序 View

uwp - UWP 中的 TextBox 未触发 KeyDown 事件

c++ - DeviceIoControl 调用崩溃

delphi - 绕过键盘、鼠标输入,让 SendInput 通过

windows - 如何在从 Win32::Process 启动的 Perl 进程中获取输出?

xaml - WinRT/UWP : Loading RelativePanel with XamlReader causes XamlParseException with RelativePanels Attached Properties

windows-10 - 有人对在 Windows 10 平台上加速 UFT 14.53 有任何建议吗?