WIX documentatino on Shortcut element说的是Target属性:
The value will be defaulted to the parent File when nested under a File element.
但代码
<Component Guid="MY_GUID" Id="MyAppComponent">
<File Source="SomeDll.dll" Name="SomeDll.dll" Id="SomeDll.dll" KeyPath="yes" />
<File Source="MyDll.exe" Name="MyDll.exe" Id="MyDll.exe" />
<Shortcut Id="MyApp.Shortcut" Directory="ApplicationProgramMenuDir" WorkingDirectory="INSTALLDIR" Name="MyApp" Icon="ProgramIcon.ico" Advertise="yes" />
</File>
</Component>
无法按预期工作 - 快捷方式指向dll文件并运行它显示Windwos错误消息,它无法启动带有dll扩展名的文件。
要解决这个问题,我们需要做出唯一的区别:为exe文件而不是dll设置KeyPath =“yes”属性:
<Component Guid="MY_GUID" Id="MyAppComponent">
<File Source="SomeDll.dll" Name="SomeDll.dll" Id="SomeDll.dll"/>
<File Source="MyDll.exe" Name="MyDll.exe" Id="MyDll.exe" KeyPath="yes" />
<Shortcut Id="MyApp.Shortcut" Directory="ApplicationProgramMenuDir" WorkingDirectory="INSTALLDIR" Name="MyApp" Icon="ProgramIcon.ico" Advertise="yes" />
</File>
</Component>
所以WIX文档包含错误? Target不是设置为父File元素,而是设置为祖先的Component的KeyPath?
或者是我的错误和我的代码出了什么问题?
答案 0 :(得分:0)
尝试添加<RegistryValue>
标记,如下所示:
<Component Guid="MY_GUID" Id="MyAppComponent">
<File Source="SomeDll.dll" Name="SomeDll.dll" Id="SomeDll.dll"/>
<File Source="MyDll.exe" Name="MyDll.exe" Id="MyDll.exe" KeyPath="yes" />
<Shortcut Id="MyApp.Shortcut" Directory="ApplicationProgramMenuDir" WorkingDirectory="INSTALLDIR" Name="MyApp" Icon="ProgramIcon.ico" Advertise="yes" />
</File>
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]\setup" Name="Shortcut" Type="integer" Value="1" KeyPath="yes" />
</Component>
如果您的InstallScope
为perUser
,请使用HKCU
如果您的InstallScope
为perMachine
,请使用HKLM