程序在更新后崩溃,但在干净安装时工作正常

时间:2017-01-26 10:39:47

标签: wix updates

我制作了一个C#wpf程序,此时我已准备好发布更新。我用Wix Toolkit创建了一个安装程序。所以我可以制作msi文件。但是,当我从版本1.0.0.0升级到2.0.0.0时,程序在安装后崩溃。如果我首先删除版本1.0.0.0的c#程序,然后安装版本2.0.0.0一切正常。我不知道我做错了什么。这是我的Product.wxs(我的guid ID在我的程序真实ID中):

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

  <?define ProductVersion="3.0.0.0"?>
  <?define View_TargetDir=$(var.View.TargetDir)?>
  <?define UpgradeCode="GUID-ID-FOR-UPGRADE"?>
  <!-- 
  Version 1.0
  <Product Id="GUID-ID-1" 
           Name="MIDIMACRO" 
           Language="1033" 
           Version="1.0.0.0" 
           Manufacturer="vanlooverenkoen" 
           UpgradeCode="$(var.UpgradeCode)">
  -->

  <!--
  Version 2.0
  -->
  <Product Id="GUID-ID-2"
           Name="MIDIMACRO"
           Language="1033"
           Version="$(var.ProductVersion)"
           Manufacturer="vanlooverenkoen"
           UpgradeCode="$(var.UpgradeCode)">



    <Package InstallerVersion="200" 
             Compressed="yes" 
             InstallScope="perMachine" />

    <Icon Id="icon.ico" 
          SourceFile="$(var.ProjectDir)Icon.ico" />
    <Property Id="ARPPRODUCTICON" 
              Value="icon.ico" />

    <WixVariable Id="WixUIBannerBmp" 
                 Value="Images\installer_top-banner.bmp" />

    <WixVariable Id="WixUIDialogBmp" 
                 Value="Images\installer_background.bmp" />

    <Property Id="WIXUI_INSTALLDIR" 
              Value="INSTALLFOLDER" />

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

    <MajorUpgrade Schedule="afterInstallInitialize"
                  DowngradeErrorMessage="A newer version of [ProductName] is already installed."/>

    <MediaTemplate EmbedCab="yes" />

    <Feature Id="ProductFeature" Title="MIDIMACRO" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
      <ComponentGroupRef Id="ProgramFilesFolder_files" />
      <ComponentRef Id="ApplicationShortcut" />
      <ComponentRef Id="ApplicationShortcutDesktop" />
    </Feature>

    <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch MIDIMACRO" />

    <!-- Step 3: Include the custom action -->
    <Property Id="WixShellExecTarget" Value="[INSTALLFOLDER]MIDIMACRO.exe" />
    <CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="MIDIMACRO" />
      </Directory>
      <Directory Id="ProgramMenuFolder">
        <Directory Id="ApplicationProgramsFolder" Name="MIDIMACRO" />
      </Directory>
      <Directory Id="DesktopFolder" Name="Desktop" />
    </Directory>
  </Fragment>

  <Fragment>
    <DirectoryRef Id="ApplicationProgramsFolder">
      <Component Id="ApplicationShortcut" Guid="9bd13330-6540-406f-a3a8-d7f7c69ae7f9">
        <Shortcut Id="ApplicationStartMenuShortcut" Name="MIDIMACRO" Description="MIDIMACRO" Target="[INSTALLFOLDER]MIDIMACRO.exe" WorkingDirectory="INSTALLFOLDER" />
        <RemoveFolder Id="RemoveApplicationProgramsFolder" Directory="ApplicationProgramsFolder" On="uninstall" />
        <RegistryValue Root="HKCU" Key="Software\MIDIMACRO" Name="installed" Type="integer" Value="1" KeyPath="yes" />
      </Component>
    </DirectoryRef>
    <DirectoryRef Id="DesktopFolder">
      <Component Id="ApplicationShortcutDesktop" Guid="cde1e030-eb64-49a5-b7b8-400b379c2d1a">
        <Shortcut Id="ApplicationDesktopShortcut" Name="MIDIMACRO" Description="MIDIMACRO" Target="[INSTALLFOLDER]MIDIMACRO.exe" WorkingDirectory="INSTALLFOLDER" />
        <RemoveFolder Id="RemoveDesktopFolder" Directory="DesktopFolder" On="uninstall" />
        <RegistryValue Root="HKCU" Key="Software\MIDIMACRO" Name="installed" Type="integer" Value="1" KeyPath="yes" />
      </Component>
    </DirectoryRef>
  </Fragment>

  <Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
      <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
      <!-- <Component Id="ProductComponent"> -->
      <!-- TODO: Insert files, registry keys, and other resources here. -->
      <!-- </Component> -->
      <Component Id="MahApps.Metro.dll" Guid="7903f312-19fb-45a5-8dc6-9823ada4cca0">
        <File Id="MahApps.Metro.dll" Name="MahApps.Metro.dll" Source="$(var.View_TargetDir)MahApps.Metro.dll" />
      </Component>
      <Component Id="System.Windows.Interactivity.dll" Guid="4af9d18a-6205-4b23-887c-bf31685d548e">
        <File Id="System.Windows.Interactivity.dll" Name="System.Windows.Interactivity.dll" Source="$(var.View_TargetDir)System.Windows.Interactivity.dll" />
      </Component>
      <Component Id="Newtonsoft.Json.dll" Guid="a97d5ecb-a716-43da-bd5f-83a7be929b47">
        <File Id="Newtonsoft.Json.dll" Name="Newtonsoft.Json.dll" Source="$(var.View_TargetDir)Newtonsoft.Json.dll" />
      </Component>
      <Component Id="Sanford.Multimedia.Midi.dll" Guid="e098aa86-d81e-48e9-84ba-4bc548e3f074">
        <File Id="Sanford.Multimedia.Midi.dll" Name="Sanford.Multimedia.Midi.dll" Source="$(var.View_TargetDir)Sanford.Multimedia.Midi.dll" />
      </Component>
      <Component Id="Controller.dll" Guid="2d5d325c-234a-4ae4-b3fb-c87d346fccf5">
        <File Id="Controller.dll" Name="Controller.dll" Source="$(var.View_TargetDir)Controller.dll" />
      </Component>
      <Component Id="View.exe.config" Guid="e1f88ab9-55fb-4bcc-a88c-2834c63469e6">
        <File Id="View.exe.config" Name="MIDIMACRO.exe.config" Source="$(var.View_TargetDir)View.exe.config" />
      </Component>
      <Component Id="View.exe" Guid="7388a307-32fa-4f56-8fc6-a558de5ab7e6">
        <File Id="View.exe" Name="MIDIMACRO.exe" Source="$(var.View_TargetDir)View.exe" />
      </Component>
      <Component Id="Model.dll" Guid="2684cc98-d124-41d4-85e6-99ecc2c7e131">
        <File Id="Model.dll" Name="Model.dll" Source="$(var.View_TargetDir)Model.dll" />
      </Component>
      <Component Id="MaterialDesignThemes.Wpf.dll" Guid="ccbfeca9-31fe-4d5c-a31a-5a264f69fd58">
        <File Id="MaterialDesignThemes.Wpf.dll" Name="MaterialDesignThemes.Wpf.dll" Source="$(var.View_TargetDir)MaterialDesignThemes.Wpf.dll" />
      </Component>
      <Component Id="MaterialDesignThemes.MahApps.dll" Guid="66e05999-a097-4595-bffe-99e4afef2369">
        <File Id="MaterialDesignThemes.MahApps.dll" Name="MaterialDesignThemes.MahApps.dll" Source="$(var.View_TargetDir)MaterialDesignThemes.MahApps.dll" />
      </Component>
      <Component Id="MaterialDesignColors.dll" Guid="28ef4cb6-386f-4c82-8999-39ff3e1cde9a">
        <File Id="MaterialDesignColors.dll" Name="MaterialDesignColors.dll" Source="$(var.View_TargetDir)MaterialDesignColors.dll" />
      </Component>
      <Component Id="WindowsInput.dll" Guid="0a28ba53-41df-42b0-b997-cc7e86a47180">
        <File Id="WindowsInput.dll" Name="WindowsInput.dll" Source="$(var.View_TargetDir)WindowsInput.dll" />
      </Component>
      <Component Id="Hardcodet.Wpf.TaskbarNotification.dll" Guid="1f4aaa97-ed7c-4d12-ac25-d5b0ba0fb734">
        <File Id="Hardcodet.Wpf.TaskbarNotification.dll" Name="Hardcodet.Wpf.TaskbarNotification.dll" Source="$(var.View_TargetDir)Hardcodet.Wpf.TaskbarNotification.dll" />
      </Component>
      <Component Id="CSCore.dll" Guid="6dcfcc86-12d8-42f6-a297-87560a5a3182">
        <File Id="CSCore.dll" Name="CSCore.dll" Source="$(var.View_TargetDir)CSCore.dll" />
      </Component>
      <Component Id="MaterialDesignThemes.Wpf.pdb" Guid="9bf8b60e-6944-4e65-b2e6-35d826ffff3d">
        <File Id="MaterialDesignThemes.Wpf.pdb" Name="MaterialDesignThemes.Wpf.pdb" Source="$(var.View_TargetDir)MaterialDesignThemes.Wpf.pdb" />
      </Component>
      <Component Id="System.Reactive.PlatformServices.dll" Guid="1e4cf4a5-ec59-41de-b42a-1de602185483">
        <File Id="System.Reactive.PlatformServices.dll" Name="System.Reactive.PlatformServices.dll" Source="$(var.View_TargetDir)System.Reactive.PlatformServices.dll" />
      </Component>
      <Component Id="System.Reactive.Linq.dll" Guid="3253a150-0b73-4dde-902e-93ecb4f3039b">
        <File Id="System.Reactive.Linq.dll" Name="System.Reactive.Linq.dll" Source="$(var.View_TargetDir)System.Reactive.Linq.dll" />
      </Component>
      <Component Id="System.Reactive.Interfaces.dll" Guid="02c68719-7df6-4814-ab49-c5c2660448c4">
        <File Id="System.Reactive.Interfaces.dll" Name="System.Reactive.Interfaces.dll" Source="$(var.View_TargetDir)System.Reactive.Interfaces.dll" />
      </Component>
      <Component Id="System.Reactive.Core.dll" Guid="11757dde-fbdc-489b-8de5-2e12bbdce7c0">
        <File Id="System.Reactive.Core.dll" Name="System.Reactive.Core.dll" Source="$(var.View_TargetDir)System.Reactive.Core.dll" />
      </Component>
      <Component Id="MaterialDesignColors.pdb" Guid="b689cffb-a71f-45a1-83cd-97e9e265d491">
        <File Id="MaterialDesignColors.pdb" Name="MaterialDesignColors.pdb" Source="$(var.View_TargetDir)MaterialDesignColors.pdb" />
      </Component>
      <Component Id="View.pdb" Guid="d8b9af45-0c0d-4cb3-b5e2-8b2cfe3e66cf">
        <File Id="View.pdb" Name="View.pdb" Source="$(var.View_TargetDir)View.pdb" />
      </Component>
      <Component Id="MaterialDesignThemes.MahApps.pdb" Guid="0623abd7-239e-41b3-aa8c-e0c76272eb0d">
        <File Id="MaterialDesignThemes.MahApps.pdb" Name="MaterialDesignThemes.MahApps.pdb" Source="$(var.View_TargetDir)MaterialDesignThemes.MahApps.pdb" />
      </Component>
      <Component Id="Firebase.Database.dll" Guid="598ae72f-65e9-4b12-a88f-480e47c9f02c">
        <File Id="Firebase.Database.dll" Name="Firebase.Database.dll" Source="$(var.View_TargetDir)Firebase.Database.dll" />
      </Component>
      <Component Id="Controller.pdb" Guid="08fa8a12-2c45-4bf8-8d68-6d036117331d">
        <File Id="Controller.pdb" Name="Controller.pdb" Source="$(var.View_TargetDir)Controller.pdb" />
      </Component>
      <Component Id="Model.pdb" Guid="1d408632-0906-4ef1-82d8-197b7665a03a">
        <File Id="Model.pdb" Name="Model.pdb" Source="$(var.View_TargetDir)Model.pdb" />
      </Component>
    </ComponentGroup>
  </Fragment>

  <Fragment>

    <ComponentGroup Id="ProgramFilesFolder_files" Directory="ProgramFilesFolder">

      <Component Id="resources_settings_icon.svg" Guid="7f417c29-b7f8-4282-b248-cb220436c6e0">

        <File Id="resources_settings_icon.svg" Name="settings_icon.svg" Source="$(var.View_TargetDir)resources\settings_icon.svg" />

      </Component>

      <Component Id="resources_search_icon.svg" Guid="12291d78-6c79-4b35-9435-025a7bd4b063">

        <File Id="resources_search_icon.svg" Name="search_icon.svg" Source="$(var.View_TargetDir)resources\search_icon.svg" />

      </Component>

      <Component Id="resources_flash_icon.svg" Guid="d84b95d6-bc6c-43d0-b7a3-15da8332cb2e">

        <File Id="resources_flash_icon.svg" Name="flash_icon.svg" Source="$(var.View_TargetDir)resources\flash_icon.svg" />

      </Component>

      <Component Id="resources_gesture_icon.svg" Guid="3e5d81c5-7801-4fb3-9dda-4ba1fb593a87">

        <File Id="resources_gesture_icon.svg" Name="gesture_icon.svg" Source="$(var.View_TargetDir)resources\gesture_icon.svg" />

      </Component>

      <Component Id="resources_add_circle_icon.svg" Guid="f56738c4-876a-4db3-8958-9d714450f1fa">

        <File Id="resources_add_circle_icon.svg" Name="add_circle_icon.svg" Source="$(var.View_TargetDir)resources\add_circle_icon.svg" />

      </Component>

    </ComponentGroup>

  </Fragment>
</Wix>

1 个答案:

答案 0 :(得分:3)

最可能的问题是日志中的消息:

禁止安装组件:{CCBFECA9-31FE-4D5C-A31A-5A264F69FD58},因为存在具有更高版本密钥文件的相同组件

这意味着您没有更新该Dll的文件版本。结果是Dll丢失,您的应用程序崩溃。这里有一个很好的解释:

https://blogs.msdn.microsoft.com/astebner/2015/11/16/why-windows-installer-removes-files-during-a-major-upgrade-if-they-go-backwards-in-version-numbers/

基本问题是,在安装的早期,它决定不会覆盖该文件,因为系统上的现有版本大于“新”传入文件,因此决定不安装它。这些是文件版本覆盖规则。但是,稍后升级会删除所有旧文件,但它仍然错误地认为它不应该安装该文件,因此在安装结束时它会丢失。