如何正确设置 AppExecutionAlias 以便程序可以从命令行启动? [英] How to properly set AppExecutionAlias so the program could be launched from command line?

查看:37
本文介绍了如何正确设置 AppExecutionAlias 以便程序可以从命令行启动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此 WPF 应用程序的 Package.appxmanifest 已设置

The Package.appxmanifest for this WPF app has already set

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

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

but when I try to run PROGRAMNAME from command line there is an error message

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

我可以转到那个 WindowsApps 目录,即使我看到了那个文件,运行它也会给我同样的错误.

I can go to that WindowsApps directory and even though I see that file, running it gives me the same error.

我也试过

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

推荐答案

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

A couple of things to note and fix here:
1. 'Executable' needs to have the actual executable path. Typically the EXE is located in a sub folder that the VS packaging project creates
2. The $targetnametoken$ replacement won't work in extensions unfortunately. So you have to put the actual folder and file names here
3. The 'Alias' property can contain whatever name you want to use for launching your app, it could be it's actual executable name, or an alias of your choice

  <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!AovTw​​KUMywTNv7oKzN9nznoZmK6XSw

Sharing my working test project here:
https://1drv.ms/u/s!AovTwKUMywTNv7oKzN9nznoZmK6XSw

这篇关于如何正确设置 AppExecutionAlias 以便程序可以从命令行启动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆