windows - 没有图标的 UWP 控制台应用程序,只有执行别名

标签 windows uwp desktop-bridge appx desktop-app-converter

我有一个使用桌面桥移植到 UWP 的 Win32 应用程序。

该应用程序同时具有 GUI 和命令行界面(单独的可执行文件)。

我想要 GUI 界面的图标和执行别名,但只有命令行界面的执行别名。我不想用一个没人会用的图标污染开始菜单。

为此,我了解到 list 需要包含两个 Application elements ,一个用于 GUI,一个用于命令行界面,因为一个 Application 只能包含一个 AppExecutionAlias .

另见 Create a Universal Windows Platform console app .

我的想法是这样的:

<Applications>
  <!-- GUI -->
  <Application Id="MyApp" Executable="MyApp.exe" EntryPoint="Windows.FullTrustApplication">
    <!-- with icon -->
    <uap:VisualElements DisplayName="MyApp" Description="MyApp" ...>
      ...
    </uap:VisualElements>
    <!-- and execution alias -->
    <Extensions>
      <uap5:Extension Category="windows.appExecutionAlias"
          Executable="MyApp.exe" EntryPoint="Windows.FullTrustApplication">
        <uap5:AppExecutionAlias>
          <uap5:ExecutionAlias Alias="MyApp.exe" />
        </uap5:AppExecutionAlias>
      </uap5:Extension>
    </Extensions>
  </Application>

  <!-- Command-line interface -->
  <Application Id="MyApp-commandline" Executable="MyApp-commandline.exe"
      EntryPoint="Windows.FullTrustApplication">
    <!-- with execution alias only -->
    <Extensions>
      <uap5:Extension Category="windows.appExecutionAlias"
          Executable="MyApp-commandline.exe" EntryPoint="Windows.FullTrustApplication">
        <uap5:AppExecutionAlias>
          <uap5:ExecutionAlias Alias="MyApp-commandline.exe" />
        </uap5:AppExecutionAlias>
      </uap5:Extension>
    </Extensions>
  </Application>
</Applications>

但我无法找到如何(如果可能的话)没有图标的 Application,因为 VisualElements 似乎是部分是强制性的。所以上面的 list 是无效的。其中有一些技巧可以为(第一个也是唯一的)Application 添加另一个执行别名(用于不同的二进制文件)。

最佳答案

是的,正如文件所警告的那样,VisualElements 部分是强制性的,我们应该遵循 .Manifest 文件所要求的规则。但是如果你不想有一些图标,你可以尝试提供一个不引用真实图像资源的 URI。比如,

<uap:VisualElements
  DisplayName="ConsoleUWP"
  Square150x150Logo="Square150x150Logo.png"
  Square44x44Logo="Image.png"
  Description="ConsoleUWP"
  BackgroundColor="transparent">
  <uap:DefaultTile Wide310x150Logo="Image.png"/>
  <uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>

Square44x44LogoSquare150x150LogoWide310x150Logo 没有引用正确的图像 URI,但是 uap:SplashScreen 不能配置错误的 URI,否则会报错。

---更新---

我们可以使用 Applications 元素为包指定一个或多个应用程序,但每个应用程序都需要 UWP .manefest 文件中的 VisualElements 部分。因此,如果您添加另一个,您将需要根据需要添加 Visual Elements,您的想法无法实现。另请注意,虽然每个包可以包含一个或多个应用,但包含多个应用的​​包将无法通过商店认证过程,也就是说您无法发布到商店。

另一方面,您可以尝试创建一个包含 Win32 和通用 Windows 平台 (UWP) 进程的程序包,并通过 AppService API 在它们之间进行通信。它使用 FullTrustProcessLauncher扩展而不是另一个。您可以尝试查看示例:

https://github.com/Microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/AppServiceBridgeSample

关于windows - 没有图标的 UWP 控制台应用程序,只有执行别名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51267935/

相关文章:

c++ - Hook ishellfolder enumobjects

c# - UWP - 打印网页 View

uwp - 如果满足条件,我可以卸载家长控制 UWP 应用程序吗?

uwp - 如何像 Windows Build 一样创建 UWP 安装程序

c++ - 确定 C++ 应用程序是否作为 UWP 应用程序在 Desktop Bridge (Project Centennial) 中运行

c# - 找不到错误文件 'MakePri.exe'

c++ - 什么是 : MultiByteToWideChar & WideCharToMultiByte? 的 Linux 等价物

windows - 在指定时间后停止批处理脚本的最佳方法是什么?

windows - 什么是压缩的 GUID,为什么要使用它?

c# - uwp 以编程方式关闭浏览器