如何正确设置AppExecutionAlias以便可以从命令行启动程序?

时间:2019-03-29 23:19:50

标签: uwp windows-10 win-universal-app desktop-bridge appxmanifest

此WPF应用的Package.appxmanifest已设置

<uap5:Extension Category="windows.appExecutionAlias" Executable="PROGRAMNAME.exe"
    EntryPoint="Windows.FullTrustApplication">
          <uap5:AppExecutionAlias>
            <uap5:ExecutionAlias Alias="PROGRAMNAME.exe" />
          </uap5:AppExecutionAlias>
        </uap5:Extension>

但是当我尝试从命令行运行PROGRAMNAME时,出现错误消息

"The system cannot find the file ....WindowsApps..."

我可以转到该WindowsApps目录,即使我看到该文件,运行它也给我同样的错误。

我也尝试过

<uap3:Extension
    Category="windows.appExecutionAlias"
    Executable="$targetnametoken$.exe"
    EntryPoint="Windows.FullTrustApplication">
          <uap3:AppExecutionAlias>
            <desktop:ExecutionAlias Alias="PROGRAMNAME.exe" />
          </uap3:AppExecutionAlias>
        </uap3:Extension>

Screenshot of command line output and dir content

1 个答案:

答案 0 :(得分:2)

此处需要注意并修复的几件事:
1.“可执行文件”需要具有实际的可执行文件路径。通常,EXE位于VS打包项目创建的子文件夹中
2.不幸的是,$ targetnametoken $替代品在扩展程序中不起作用。所以你必须在这里放置实际的文件夹和文件名
3.'Alias'属性可以包含您想要用来启动应用程序的任何名称,可以是实际的可执行文件名称,也可以是您选择的别名

  <uap3:Extension
      Category="windows.appExecutionAlias"
      Executable="WpfApp4\WpfApp4.exe"
      EntryPoint="Windows.FullTrustApplication">
    <uap3:AppExecutionAlias>
      <desktop:ExecutionAlias Alias="foo.exe" />
    </uap3:AppExecutionAlias>
  </uap3:Extension>  

在这里共享我的工作测试项目:
https://1drv.ms/u/s!AovTwKUMywTNv7oKzN9nznoZmK6XSw