How to properly set AppExecutionAlias so the program could be launched from command line?

梦想的初衷 提交于 2021-02-07 19:48:57

问题


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>

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

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

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

I have also tried

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


回答1:


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>  

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



来源:https://stackoverflow.com/questions/55426605/how-to-properly-set-appexecutionalias-so-the-program-could-be-launched-from-comm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!