EXE文件无效

时间:2018-02-06 20:17:01

标签: c# wix windows-installer exe msiexec

我的项目中有一个.msi(Windows安装程序包)文件。我成功地从.msi文件生成了.exe文件但是每当我尝试打开该.exe文件或以管理员身份运行时它什么都不做。怎么解决这个?对此有所帮助。请帮忙

更新 这是我的.msi文件的代码

components.wxs

    <?xml version="1.0" encoding="UTF-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">

    <?include Defines.wxi?>

    <Fragment>

    <ComponentGroup Id="MenuComponents" Directory="ProductMenuFolder">
    <Component Id="ProductMenuComponents" Guid="*">

    <!--<Shortcut Id="UninstallPackage" Directory="ProductMenuFolder" Name="Uninstall package"
          Target="[System64Folder]msiexec.exe" Arguments="/x {[ProductCode]}" Description="Uninstalls $(var.YourApplicationReference.TargetName)"/>-->
<RemoveFolder Id='ProductMenuFolder' On='uninstall' />
<RegistryValue Root='HKCU' Key='Software\[Manufacturer]\[ProductName]' 
Type='string' Value='' KeyPath='yes' />

   </Component>
   </ComponentGroup>

   <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
   <Component Id="FileWatcher">
   <File Source="$(var.FileWatcher.TargetPath)" />

   <!--Register this file as a Windows service-->
   <ServiceInstall Id="ServiceInstaller"
                Type="ownProcess"
                Description="Sends Incoming mainframe files to the  Webservice"
                DisplayName="FileWatcher"
                Vital="yes"
                Start="auto"
                ErrorControl="ignore"
                Interactive="no"
                Name="FileWatcher"
                Account="[ACCOUNT]"
                Password="[PASSWORD]">

      <ServiceConfig Id="svcConfig" DelayedAutoStart="yes" OnInstall="yes" OnReinstall="yes" OnUninstall="no" />
</ServiceInstall>

     <!--Set the user to be used by the service-->
     <util:User Id="ServiceUser" Name="[ACCOUNT]" Password="[PASSWORD]" CreateUser="no" LogonAsService="yes" UpdateIfExists="yes" />

     <!--Added example of how to stop service automatically-->
     <ServiceControl Id="ServiceControl" Stop="both" Remove="uninstall" Name="FileWatcher" Wait="yes" />
     </Component>
     <Component Id="FileWatcher.Files" Guid="*">
     <!--<Component Id="MAIDFileWatcher.Files" Guid="*">-->
     <File Id="filB93E7D71690869B9CD2D0A479DB69C6C" Source="$(var.FileWatcher.TargetDir)\ExceptionHandling.dll"  />
    <File Id="fil487232F7A833919419AF9537A4390083" Source="$(var.FileWatcher.TargetDir)\ExceptionHandling.xml" />
    <File Id="filDE3649B71309470D2D7C086E0FAABAE8" Source="$(var.FileWatcher.TargetDir)\itextsharp.dll"  />
    <File Id="filF73350F1AEF9ECF2621D4E63B9823029" Source="$(var.FileWatcher.TargetDir)\FileWatcher.exe.config"  KeyPath='yes'/>
    </Component>
    </ComponentGroup>

product.wxs

   <?xml version="1.0" encoding="UTF-8"?>
   <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

   <?include Version.wxi?>
   <?include Defines.wxi?>

   <Product Id="$(var.PRODUCTCODE)" Name="$(var.PRODUCTNAME)" Language="1033" Version="$(var.REVISION)" Manufacturer="$(var.MANUFACTURER)" UpgradeCode="$(var.UPGRADECODE)">

   <Package InstallerVersion="400" Compressed="yes" InstallScope="perMachine" Comments="$(var.COMMENTS)" Description="$(var.DESCRIPTION)" />

   <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
   <MediaTemplate EmbedCab="yes" />

   <Feature Id="ProductFeature" Title="$(var.PRODUCTNAME)" Level="1">
    <ComponentGroupRef Id="ProductComponents" />
    <ComponentGroupRef Id="MenuComponents"/>
   </Feature>

   <UIRef Id="USERUI" />

   <?include Actions.wxi?> 

   </Product>

   </Wix>

4 个答案:

答案 0 :(得分:0)

您可以使用如下命令行调试msi安装:

msiexec /i someapplication.msi /L*vx log.txt

这将运行安装程序并将日志信息输出到名为 log.txt 的文件。

另请参阅:Windows Installer Command Line Options

答案 1 :(得分:0)

另一个专业提示是在虚拟机中调试安装程序。在安装之前拍摄快照,以便您可以回滚,或在更改代码后从重现状态开始重复安装。我无法想象没有Hyper-V的调试安装程序 - 这对我来说非常重要。

答案 2 :(得分:0)

这基本上只是从臀部拍摄,请忽略任何不相关的内容(也许先查看最后三个要点):

最佳实践 :首先,您要使用单个组件安装多个二进制文件。这违反了component creation best practice

  • 对于这么小的东西,我建议你每个文件使用一个组件。这解决了修补,升级和其他方面的各种未来问题。

  • What happens if the component rules are broken?请浏览一下,或者接受我们的说法,每个组件只使用一个文件。至少为所有二进制文件创建一个单独的组件(必需)。

  • 关于组件GUID的性质和哲学的一点点模糊:Change my component GUID in wix?有些人发现了解神秘且总是很麻烦的组件GUID很有帮助。

  • 如果您坚持每个组件使用多个文件,请确保该组件的密钥文件是版本化文件。我认为WiX会自动魔术。

    • 如果您没有版本化的密钥文件,如果目标位置中已有文件,则可能会导致组件无法安装。

    • 如果您有版本化密钥文件,请确保您的安装版本的二进制文件版本高于目标位置磁盘上可能遇到的版本二进制文件(如果有)。请阅读the MSI file versioning rules以获取解释。

日志记录 :您的应用程序是否具有可用于调试的日志功能(默认情况下或您可以启用的功能)?也许到系统的事件日志?不会在那里写服务吗?

依赖 :另外,您是否检查了我之前提供的有关依赖性检查的指针? C# Debug folder when copied to another location does not run the exe

服务凭证 :您确定在安装期间是否已应用这些登录凭据

  • 您是否尝试手动设置它们以查看该服务是否会运行?您是否已将这些属性添加到允许传递给延迟安装模式的SecureCustomProperties属性列表中?
  • 我认为WiX有&#34;自动魔术&#34;在这里为你做这件事,我忘记了。检查最终编译的MSI using an appropriate tool, for example Orca的属性表中的SecureCustomProperties。
  • 使用延迟服务启动设置,服务是否正在运行? (至少要提到它)。或者你说它在发射时崩溃了吗?

硬编码参考 :缺少资源的指针。

  • 您是否检查了所有清单文件配置文件FileWatcher.exe.config)以查找指向开发人员资源上的资源的任何内容(错误,难以处理)编码参考文件)?
  • 可能缺少资源文件吗? (图像,dll等......)。

架构&amp;运行时要求 :目标计算机与开发人员计算机具有相同的体系结构吗?只是为了粉笔,你肯定会看到关于这个的警告吗?

  • 您的代码所针对的CPU是什么?任何CPU?您是否尝试在另一台计算机上手动注册文件(可能是干净的虚拟机)。
  • 这个问题有什么特别之处,目标计算机?它有奇怪的政策吗?是否有安全软件阻止事情?您的开发计算机上是否缺少通用运行时组件? (.NET,VC ++运行时,VC运行时,java等)。这些是procmon.exe会话应该显示的内容,或者是Dependencies.exe应该显示的检查。
  • 您使用的是臭名昭着的FileSystemWatcher .NET类吗?我多年前才使用过它,但它给我带来了很多的悲伤,我不得不停止使用它。它确实会定期崩溃我的服务文件。

答案 3 :(得分:0)

  • 当我在%PROGRAMDATA%下安装EXE时,我遇到了同样的问题
  • 当我在%PROGRAMFILES%下安装我的EXE时,我解决了问题
相关问题