wix c# 应用程序在安装后无法启动
wix c# app doesn't launch after installing
我已经使用 Wix 成功生成并安装了我的 C# WPF 应用程序。该应用程序包括 Crystal 报告 dll 和一些其他 dll,如 Zen Barecode。
在第 n 次尝试修改主项目后,MSI 能够自行安装,但是通过直接从快捷方式或可执行文件启动应用程序,它无法启动。
这是我的 Wix product.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
Name="MyApp 1.0.0"
Language="1036"
Codepage="1252"
Version="1.0.0"
Manufacturer="My Company"
UpgradeCode="PUT-GUID-HERE">
<Package InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine"
Description="Some description"
Keywords="Some keywords"
Comments="(c) some comments"
/>
<MajorUpgrade DowngradeErrorMessage="La dernière version de MyApp est déjà installée" />
<MediaTemplate EmbedCab="yes" />
<Icon Id="icon.ico" SourceFile="$(var.InstallFolderPath)\logo.ico"/>
<Feature Id="ProductFeature" Title="TPI SOFT" Level="1">
<ComponentGroupRef Id="ProductComponents" />
<ComponentGroupRef Id="LibrariesComponents" />
<ComponentGroupRef Id="CustomFonts" />
<ComponentRef Id="CMP_MenuShortcut" />
<ComponentRef Id="CMP_DesktopShortcut" />
</Feature>
<Property Id="ARPPRODUCTICON"
Value="icon.ico" />
<Property Id="ARPCONTACT"
Value="My Contact"/>
<PropertyRef Id="NETFRAMEWORK45"/>
<Condition Message="Ce logiciel requiert l'installation préalable de Microsoft .NET Framework 4.5 ou plus.">
<![CDATA[Installed OR NETFRAMEWORK45]]>
</Condition>
<Condition Message="Ce logiciel tourne sur tous les systèmes Windows à partir de Windows Vista">
<![CDATA[Installed OR VersionNT >= 600]]>
</Condition>
<Property Id="WIXUI_INSTALLDIR" Value="APPLICATIONFOLDER" />
<UIRef Id="WixUI_InstallDir" />
<WixVariable Id="WixUILicenseRtf"
Value="$(var.InstallFolderPath)\licence.rtf" />
<WixVariable Id="WixUIDialogBmp"
Value="$(var.InstallFolderPath)\dialog_bmp.bmp"/>
<WixVariable Id="WixUIBannerBmp"
Value="$(var.InstallFolderPath)\top_banner.bmp"/>
<Property Id="ApplicationFolderName"
Value="MyApp\MyApp" />
<Property Id="WixAppFolder"
Value="WixPerMachineFolder" />
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="COMPANYFOLDER" Name="My Company">
<Directory Id="APPLICATIONFOLDER" Name="My App 1.0.0">
</Directory>
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="MyStartMenuShortcutDir"
Name="My App"/>
</Directory>
<Directory Id="DesktopFolder">
</Directory>
<Directory Id="FontsFolder">
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="APPLICATIONFOLDER">
<Component Id="cmp436C9F728138518252041AF1E09808A9" Guid="PUT-GUID-HERE">
<File Id="filC9EEE3E54616B953432FF36EDA3020A3" KeyPath="yes" Source="$(var.MyApp.TargetDir)MyApp.exe" />
</Component>
<Component Id="cmp840D318334E734AB5C8FA4C807C4CB95" Guid="PUT-GUID-HERE">
<File Id="filE698BF079DEBA8E2BC7F2E69833E372D" KeyPath="yes" Hidden="yes" Source="$(var.MyApp.TargetDir)MyApp.exe.config" />
</Component>
<Component Id="CMP_Licence"
Guid="558784B2-E92A-4686-95BD-A034E859E8A7">
<File Id="licence"
Source="$(var.InstallFolderPath)\licence.rtf"
KeyPath="yes" />
</Component>
</ComponentGroup>
<ComponentGroup Id="CustomFonts" Directory="FontsFolder">
<Component Id="CMP_DigitalFont"
Guid="PUT-GUID-HERE">
<File Id="digitalFont"
Source="$(var.FontFolderPath)\digital-7.ttf"
TrueType="yes"
KeyPath="yes" />
</Component>
</ComponentGroup>
<Component Id="CMP_MenuShortcut"
Directory="MyStartMenuShortcutDir"
Guid="PUT-GUID-HERE">
<Shortcut Id="MenuShortcut"
Name="MyApp 1.0.0"
Description="Lance le logiciel MyApp"
Target="[APPLICATIONFOLDER]MyApp.exe"
WorkingDirectory="APPLICATIONFOLDER"
Icon="icon.ico"/>
<RemoveFolder Id="RemoveMyStartMenuShortcutDir"
On="uninstall" />
<RegistryValue Root="HKCU"
Key="Software\MyApp"
Name="installed"
Type="integer"
Value="2"
KeyPath="yes" />
</Component>
<Component Id="CMP_DesktopShortcut"
Directory="DesktopFolder"
Guid="PUT-GUID-HERE">
<Shortcut Id="DesktopShortcut"
Name="MyApp 1.0.0"
Description="Lance le logiciel MyApp"
Target="[APPLICATIONFOLDER]MyApp.exe"
WorkingDirectory="APPLICATIONFOLDER"
Icon="icon.ico"/>
<RemoveFolder Id="DesktopFolder" On="uninstall"/>
<RegistryValue
Root="HKCU"
Key="Software\MyApp"
Name="installed"
Type="integer"
Value="1"
KeyPath="yes"/>
</Component>
</Fragment>
</Wix>
UPDATE: The issue was a missing application parameter in an outdated config file. A
configuration issue in other words. Found by attaching debugger to the launching app. See below.
日志记录:你在事件查看器或任何其他日志记录中看到任何线索了吗构建您的应用程序提供?也许您可以通过其配置文件或注册表设置为应用程序启用调试日志记录?
启动问题检查表:我曾经写过a general-purpose check-list for application launch problems。也许看一看,看看是否有什么响起。
Debug Binaries - Launch Sequence Debugging: You could insert a message box early in your application launch sequence and slipstream
the debug binaries into your setup, install it, and then attach the
debugger to the application's message box on launch in order to step
through the launch code? (set a breakpoint).
Maybe check this nice Advanced Installer Video Tutorial for this "attach debugger approach". It shows the same approach for custom
action code. The procedure is the same for launching applications.
Just attach to message box and set breakpoints.
Note: Obviously remember to recompile with the release binaries once you know what the problem is - and retest launching. Debug
binaries are not redistributable - they bind to debug dlls only
installed by the MS SDK. Normal PCs will not (normally) have these
debug dlls (making this procedure primarily about configuration problems and not about runtime dependency issues).
更新后的免责声明:
Disclaimer: Though obvious, it has to be mentioned: never use debug binaries for actual release. 1)
Not at all legal, 2)
not a good idea due to the transparency
and reverse-engineering possibilities of debug binaries, and 3)
debug runtime binaries will not exist on non-developer boxes (and don't be tempted to statically link). And finally: it
could be easy to forget to rebuild with release binaries when you mess around with debugging like this. It sure happens.
类似答案:我不会在这里重复自己,而是 link 之前的一些类似答案。请浏览一下,看看你是否看到任何响铃的东西:
- Which winform project files should be packed up into the installer
在严格按照 Stein 的二进制调试指南(因为这是我的第一次,所以花了一点时间来完成)之后,我在我的应用程序的执行序列中附加了一条框消息(恰好在 App 的构造函数中 class of my application WPF),然后直接在消息框后面的指令上设置断点。然后我生成了应用程序,重新创建了 msi,然后安装了 msi。从桌面快捷方式启动可执行文件后,会出现消息框。在单击消息框的“确定”按钮之前,我输入了我的源代码,我附加了我的应用程序的进程(调试 -> 附加到进程)。 Visual Studio消息框的验证返回给我,我能够一步一步地按照代码部分,直到回到小公寓。
我已经使用 Wix 成功生成并安装了我的 C# WPF 应用程序。该应用程序包括 Crystal 报告 dll 和一些其他 dll,如 Zen Barecode。 在第 n 次尝试修改主项目后,MSI 能够自行安装,但是通过直接从快捷方式或可执行文件启动应用程序,它无法启动。
这是我的 Wix product.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
Name="MyApp 1.0.0"
Language="1036"
Codepage="1252"
Version="1.0.0"
Manufacturer="My Company"
UpgradeCode="PUT-GUID-HERE">
<Package InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine"
Description="Some description"
Keywords="Some keywords"
Comments="(c) some comments"
/>
<MajorUpgrade DowngradeErrorMessage="La dernière version de MyApp est déjà installée" />
<MediaTemplate EmbedCab="yes" />
<Icon Id="icon.ico" SourceFile="$(var.InstallFolderPath)\logo.ico"/>
<Feature Id="ProductFeature" Title="TPI SOFT" Level="1">
<ComponentGroupRef Id="ProductComponents" />
<ComponentGroupRef Id="LibrariesComponents" />
<ComponentGroupRef Id="CustomFonts" />
<ComponentRef Id="CMP_MenuShortcut" />
<ComponentRef Id="CMP_DesktopShortcut" />
</Feature>
<Property Id="ARPPRODUCTICON"
Value="icon.ico" />
<Property Id="ARPCONTACT"
Value="My Contact"/>
<PropertyRef Id="NETFRAMEWORK45"/>
<Condition Message="Ce logiciel requiert l'installation préalable de Microsoft .NET Framework 4.5 ou plus.">
<![CDATA[Installed OR NETFRAMEWORK45]]>
</Condition>
<Condition Message="Ce logiciel tourne sur tous les systèmes Windows à partir de Windows Vista">
<![CDATA[Installed OR VersionNT >= 600]]>
</Condition>
<Property Id="WIXUI_INSTALLDIR" Value="APPLICATIONFOLDER" />
<UIRef Id="WixUI_InstallDir" />
<WixVariable Id="WixUILicenseRtf"
Value="$(var.InstallFolderPath)\licence.rtf" />
<WixVariable Id="WixUIDialogBmp"
Value="$(var.InstallFolderPath)\dialog_bmp.bmp"/>
<WixVariable Id="WixUIBannerBmp"
Value="$(var.InstallFolderPath)\top_banner.bmp"/>
<Property Id="ApplicationFolderName"
Value="MyApp\MyApp" />
<Property Id="WixAppFolder"
Value="WixPerMachineFolder" />
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="COMPANYFOLDER" Name="My Company">
<Directory Id="APPLICATIONFOLDER" Name="My App 1.0.0">
</Directory>
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="MyStartMenuShortcutDir"
Name="My App"/>
</Directory>
<Directory Id="DesktopFolder">
</Directory>
<Directory Id="FontsFolder">
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="APPLICATIONFOLDER">
<Component Id="cmp436C9F728138518252041AF1E09808A9" Guid="PUT-GUID-HERE">
<File Id="filC9EEE3E54616B953432FF36EDA3020A3" KeyPath="yes" Source="$(var.MyApp.TargetDir)MyApp.exe" />
</Component>
<Component Id="cmp840D318334E734AB5C8FA4C807C4CB95" Guid="PUT-GUID-HERE">
<File Id="filE698BF079DEBA8E2BC7F2E69833E372D" KeyPath="yes" Hidden="yes" Source="$(var.MyApp.TargetDir)MyApp.exe.config" />
</Component>
<Component Id="CMP_Licence"
Guid="558784B2-E92A-4686-95BD-A034E859E8A7">
<File Id="licence"
Source="$(var.InstallFolderPath)\licence.rtf"
KeyPath="yes" />
</Component>
</ComponentGroup>
<ComponentGroup Id="CustomFonts" Directory="FontsFolder">
<Component Id="CMP_DigitalFont"
Guid="PUT-GUID-HERE">
<File Id="digitalFont"
Source="$(var.FontFolderPath)\digital-7.ttf"
TrueType="yes"
KeyPath="yes" />
</Component>
</ComponentGroup>
<Component Id="CMP_MenuShortcut"
Directory="MyStartMenuShortcutDir"
Guid="PUT-GUID-HERE">
<Shortcut Id="MenuShortcut"
Name="MyApp 1.0.0"
Description="Lance le logiciel MyApp"
Target="[APPLICATIONFOLDER]MyApp.exe"
WorkingDirectory="APPLICATIONFOLDER"
Icon="icon.ico"/>
<RemoveFolder Id="RemoveMyStartMenuShortcutDir"
On="uninstall" />
<RegistryValue Root="HKCU"
Key="Software\MyApp"
Name="installed"
Type="integer"
Value="2"
KeyPath="yes" />
</Component>
<Component Id="CMP_DesktopShortcut"
Directory="DesktopFolder"
Guid="PUT-GUID-HERE">
<Shortcut Id="DesktopShortcut"
Name="MyApp 1.0.0"
Description="Lance le logiciel MyApp"
Target="[APPLICATIONFOLDER]MyApp.exe"
WorkingDirectory="APPLICATIONFOLDER"
Icon="icon.ico"/>
<RemoveFolder Id="DesktopFolder" On="uninstall"/>
<RegistryValue
Root="HKCU"
Key="Software\MyApp"
Name="installed"
Type="integer"
Value="1"
KeyPath="yes"/>
</Component>
</Fragment>
</Wix>
UPDATE: The issue was a missing application parameter in an outdated config file. A configuration issue in other words. Found by attaching debugger to the launching app. See below.
日志记录:你在事件查看器或任何其他日志记录中看到任何线索了吗构建您的应用程序提供?也许您可以通过其配置文件或注册表设置为应用程序启用调试日志记录?
启动问题检查表:我曾经写过a general-purpose check-list for application launch problems。也许看一看,看看是否有什么响起。
Debug Binaries - Launch Sequence Debugging: You could insert a message box early in your application launch sequence and slipstream the debug binaries into your setup, install it, and then attach the debugger to the application's message box on launch in order to step through the launch code? (set a breakpoint).
Maybe check this nice Advanced Installer Video Tutorial for this "attach debugger approach". It shows the same approach for custom action code. The procedure is the same for launching applications. Just attach to message box and set breakpoints.
Note: Obviously remember to recompile with the release binaries once you know what the problem is - and retest launching. Debug binaries are not redistributable - they bind to debug dlls only installed by the MS SDK. Normal PCs will not (normally) have these debug dlls (making this procedure primarily about configuration problems and not about runtime dependency issues).
更新后的免责声明:
Disclaimer: Though obvious, it has to be mentioned: never use debug binaries for actual release.
1)
Not at all legal,2)
not a good idea due to the transparency and reverse-engineering possibilities of debug binaries, and3)
debug runtime binaries will not exist on non-developer boxes (and don't be tempted to statically link). And finally: it could be easy to forget to rebuild with release binaries when you mess around with debugging like this. It sure happens.
类似答案:我不会在这里重复自己,而是 link 之前的一些类似答案。请浏览一下,看看你是否看到任何响铃的东西:
- Which winform project files should be packed up into the installer
在严格按照 Stein 的二进制调试指南(因为这是我的第一次,所以花了一点时间来完成)之后,我在我的应用程序的执行序列中附加了一条框消息(恰好在 App 的构造函数中 class of my application WPF),然后直接在消息框后面的指令上设置断点。然后我生成了应用程序,重新创建了 msi,然后安装了 msi。从桌面快捷方式启动可执行文件后,会出现消息框。在单击消息框的“确定”按钮之前,我输入了我的源代码,我附加了我的应用程序的进程(调试 -> 附加到进程)。 Visual Studio消息框的验证返回给我,我能够一步一步地按照代码部分,直到回到小公寓。