本文介绍了C# 应用程序(使用 WIX 创建的安装程序)在安装后不运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过几天的点击和试用,我为一个简单的解决方案创建了 WIX 安装程序,并遵循了几个教程,以便包括在安装结束时启动应用程序的选项、桌面上和添加/删除程序中带有图标的应用程序快捷方式列表.当它运行良好时,我为包含 6 个项目和 SQLite 数据库的原始项目复制了相同的过程.但是现在当我安装安装程序时,单击桌面上已安装的图标无效.它不会启动指定的 exe.请帮助我.

I created WIX installer for a simple solution after several days of hit and trial, and following several tutorials in order to include the options of launching app at the end of installation, app shortcuts with icons on desktop and in Add/Remove Programs list. When it worked fully well, I replicated the same process for my original project that contains 6 projects and SQLite db. But now when i install the installer, clicking on the installed icon on Desktop has no effect. It doesn't launch the designated exe. Kindly help me.

我应该分享 wxs 代码吗?

Should i share the wxs code?

更新:以下是我的 .wxs 文件的大部分代码.抱歉,我无法破译问题的根源,因此必须包含除标准顶部标签之外的所有代码.此外,一旦发现问题,它可以为其他 Wix 用户提供参考.

Update: Following is most of the code of my .wxs file. Sorry I could not decipher the source of problem so had to include all the code except the standard top tags. Moreover, it could be a reference for other Wix users to benefit from, once the problem is identified.

<!-- Embed cab1 file inside the package -->
<Media Id="1" Cabinet="cab1.cab" EmbedCab="yes" />

<!-- Specify Installation folders -->
<Directory Id="TARGETDIR" Name="SourceDir">
  <!-- Program Files folder i.e. on HDD -->
  <Directory Id="ProgramFilesFolder">
    <Directory Id="INSTALLFOLDER" Name="Pihu" />
  </Directory>
  <!-- Program Menu folder i.e. on Start Menu -->
  <Directory Id="ProgramMenuFolder">
    <Directory Id="ProgramMenuDir" Name="Pihu Co." />
  </Directory>
  <!-- Desktop folder-->
  <Directory Id="DesktopFolder"/>
</Directory>

<!-- Add Main App's exe-->
<DirectoryRef Id="INSTALLFOLDER">
  <Component Id="Pihu.exe" Guid="*">
    <File Id="PihuEXE" Source="../Pihu/bin/$(var.BUILD)/Pihu.exe"
          Name="Pihu.exe" KeyPath="yes"/>
  </Component>
</DirectoryRef>

<!-- Icon for Add/Remove Program must be specified separately by following 2 lines -->
<Icon Id="AddRemoveProgIcon" SourceFile="Pihu.ico"/>
<Property Id="ARPPRODUCTICON" Value="AddRemoveProgIcon" />

<!-- Add shortcut for Start Menu-->
<DirectoryRef Id="ProgramMenuDir">
  <Component Id="StartMenuShortcut" Guid="*">
        <Shortcut Id="StartMenuShortcut" Name="Pihu HMI" Description="Pihu HMI"
            Target="[INSTALLFOLDER]Pihu.exe" WorkingDirectory="INSTALLFOLDER">
          <!--Add Icon to the ShortCut-->
          <Icon Id="StartMenuIcon" SourceFile="Pihu.ico"/>
        </Shortcut>
        <RegistryValue Root="HKCU"  Key='Software\[Manufacturer]\[ProductName]'
                       Name="installed" Type="string" Value="[INSTALLFOLDER]" KeyPath="yes"/>
        <!--Remove the StartMenu folder at Uninstall time -->
        <RemoveFolder Id="StartMenuShortcut" On="uninstall"/>
      </Component>
</DirectoryRef>

<!-- Add shortcut for DeskTop-->
<DirectoryRef Id="DesktopFolder">
  <Component Id="DesktopShortcut" Guid="*">
    <Shortcut Id="DesktopShortcut" Name="Pihu HMI" Description="Pihu HMI"
              Target="[INSTALLFOLDER]Pihu.exe" WorkingDirectory="INSTALLFOLDER">
      <Icon Id="DeskTopIcon" SourceFile="Pihu.ico"/>
    </Shortcut>
    <RegistryValue Root="HKCU"  Key='Software\[Manufacturer]\[ProductName]'
                   Name="installed" Type="string" Value="[INSTALLFOLDER]" KeyPath="yes"/>
    <RemoveFolder Id="DesktopFolder" On="uninstall"/>
  </Component>
</DirectoryRef>

<WixVariable Id="WixUILicenseRtf" Value="License.rtf"/>

<!-- Add Component -->
<Feature Id="MainApplication" Title="Pihu HMI" Level="1" ConfigurableDirectory="INSTALLFOLDER">
  <ComponentRef Id="Pihu.exe" />
  <!-- Add feature for Start menu shortcut-->
  <ComponentRef Id="StartMenuShortcut" />
  <!-- Add feature for DeskTop shortcut-->
  <ComponentRef Id="DesktopShortcut" />
</Feature>

<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch Pihu HMI Application now" />
<Property Id="WixShellExecTarget" Value="[#PihuEXE]" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />

<UI>
  <UIRef Id="WixUI_FeatureTree"/>
  <Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchApplication">
    WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed
  </Publish>
</UI>

Pihu.exe 从 Debug 或 Release 文件夹运行时运行良好.第一个屏幕独立于数据库,因此不会有问题.我认为唯一的问题是解决方案是多项目(尽管所有依赖项目的 dll 也存在于 Debug 和 Release 文件夹中)

Pihu.exe runs fine when run from the Debug or Release folder. First screen is independent of the DB so that cannot be a problem. I think the only problem is the solution being multi-project (although dlls of all the dependent projects are also present in Debug as well as Release folders)

推荐答案

一旦您向问题添加更多详细信息,我将演变"这个答案.我想避免太多评论.是的,请在您的问题中分享您的 WiX 源代码的核心,或者甚至是已编译的 MSI 本身,如果它是公开的且不是太大,并且您有上传它的地方 - 链接到它.

I will "evolve" this answer once you add more details to your question. I want to avoid too many comments. And yes, please share the core of your WiX source in your question, or even the compiled MSI itself if it is public and not too large and you got a place to upload it - link to it.

请在发布前从您的 WiX 源中删除任何密码、数据库连接字符串、用户名、共享名称、IP 地址或其他敏感数据.一个好的包不应该硬编码任何这些(它们应该是最终用户在安装时设置的参数),但正如我们所知,有时硬编码的东西(通常来自你的开发箱)在安装过程中潜入源代码发展 - 给它一次.还请消除源代码中的硬编码 GUID - 将它们替换为 PUT-GUID-HERE(不是那么重要,如果您不确定如何操作,我们会帮助您做到这一点).

Please eliminate any passwords, database connection strings, user names, share names, IP-addresses, or other sensitive data from your WiX source before posting. A good package shouldn't hard-code any of this (they should be parameters set by the end user at install time), but as we know, sometimes hard-coded stuff (often from your dev-box) sneaks into the source during development - give it a once-over. Please also eliminate hard coded-GUIDs in the source - replace them with PUT-GUID-HERE (not that critical, we will help you do that if you are unsure how).