使用wix安装程序首次设置时未执行自定义事件

时间:2017-02-27 07:28:11

标签: installation wix

我正在尝试使用SingnalR开发一个应用程序,它将安装到客户端计算机上并不断给我更新特定端口。我使用WIX进行了客户端设置,并添加了一个自定义事件来将端口注册到客户端计算机。现在的问题是,当我要在客户机的第一次运行设置时,我的自定义事件不会被解雇。但如果我第二次运行安装程序,它就会被解雇。我不知道是什么问题。

.wxs文件如下,



<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <?define WixSetup2_TargetDir=$(var.WixSetup2.TargetDir)?>
  <Product Id="*" Name="TestCompany" Language="1033" Version="1.0.0.0" Manufacturer="Test" UpgradeCode="aacb5b21-2f9c-4d93-b47c-d6ec8868dc65">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" InstallPrivileges="elevated" AdminImage="yes" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of Test is already installed." />
    <MediaTemplate />

    <Feature Id="ProductFeature" Title="SetupProject1" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
      <ComponentGroupRef Id="ProgramFilesFolder_files" />
    </Feature>
  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="SetupProject1" />
      </Directory>
    </Directory>
  </Fragment>

  <Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
      <Component Id="WixSetup2.exe" Guid="ca9e28f3-b059-48db-ae8c-3ea39c471644">
        <File Id="WixSetup2.exe" Name="WixSetup2.exe" Source="$(var.WixSetup2_TargetDir)WixSetup2.exe" />
      </Component>
      <Component Id="WixSetup2.exe.config" Guid="3ac3746a-c59e-450d-a575-4c137c959309">
        <File Id="WixSetup2.exe.config" Name="WixSetup2.exe.config" Source="$(var.WixSetup2_TargetDir)WixSetup2.exe.config" />
      </Component>
      <Component Id="Owin.dll" Guid="7610272c-0faa-40b9-b633-1f251d05c360">
        <File Id="Owin.dll" Name="Owin.dll" Source="$(var.WixSetup2_TargetDir)Owin.dll" />
      </Component>
      <Component Id="Microsoft.AspNet.SignalR.Core.dll" Guid="0bb82458-a72a-49e5-adbe-36d3521f8322">
        <File Id="Microsoft.AspNet.SignalR.Core.dll" Name="Microsoft.AspNet.SignalR.Core.dll" Source="$(var.WixSetup2_TargetDir)Microsoft.AspNet.SignalR.Core.dll" />
      </Component>
      <Component Id="Microsoft.AspNet.SignalR.SystemWeb.dll" Guid="8f06a4f7-93fe-45f3-a82a-ed5d5f102d17">
        <File Id="Microsoft.AspNet.SignalR.SystemWeb.dll" Name="Microsoft.AspNet.SignalR.SystemWeb.dll" Source="$(var.WixSetup2_TargetDir)Microsoft.AspNet.SignalR.SystemWeb.dll" />
      </Component>
      <Component Id="Microsoft.Owin.dll" Guid="98e2aa07-583d-4fe5-bf0b-04c7dd544899">
        <File Id="Microsoft.Owin.dll" Name="Microsoft.Owin.dll" Source="$(var.WixSetup2_TargetDir)Microsoft.Owin.dll" />
      </Component>
      <Component Id="Microsoft.Owin.Hosting.dll" Guid="8e662dd5-27ee-46fc-aa66-513e2a2620ef">
        <File Id="Microsoft.Owin.Hosting.dll" Name="Microsoft.Owin.Hosting.dll" Source="$(var.WixSetup2_TargetDir)Microsoft.Owin.Hosting.dll" />
      </Component>
      <Component Id="Microsoft.Owin.Cors.dll" Guid="ec90a805-82c9-4293-8ef7-83b8b2675e2d">
        <File Id="Microsoft.Owin.Cors.dll" Name="Microsoft.Owin.Cors.dll" Source="$(var.WixSetup2_TargetDir)Microsoft.Owin.Cors.dll" />
      </Component>
      <Component Id="System.Web.Cors.dll" Guid="7aa9db0e-51af-4b46-bb5d-abebc7e66285">
        <File Id="System.Web.Cors.dll" Name="System.Web.Cors.dll" Source="$(var.WixSetup2_TargetDir)System.Web.Cors.dll" />
      </Component>
      <Component Id="Newtonsoft.Json.dll" Guid="ade7f021-743d-4d36-8fcd-c1a991f4b133">
        <File Id="Newtonsoft.Json.dll" Name="Newtonsoft.Json.dll" Source="$(var.WixSetup2_TargetDir)Newtonsoft.Json.dll" />
      </Component>
      <Component Id="Microsoft.Owin.Host.SystemWeb.dll" Guid="38f6eaab-041a-401c-8fdb-2f841fbcea6a">
        <File Id="Microsoft.Owin.Host.SystemWeb.dll" Name="Microsoft.Owin.Host.SystemWeb.dll" Source="$(var.WixSetup2_TargetDir)Microsoft.Owin.Host.SystemWeb.dll" />
      </Component>
      <Component Id="Microsoft.Owin.Security.dll" Guid="82ef20d9-562b-4bf4-85a0-4ea446bc5095">
        <File Id="Microsoft.Owin.Security.dll" Name="Microsoft.Owin.Security.dll" Source="$(var.WixSetup2_TargetDir)Microsoft.Owin.Security.dll" />
      </Component>
      <Component Id="Microsoft.Owin.Host.HttpListener.dll" Guid="a00da1a6-563b-4318-8bcc-eb21c5c7d7bd">
        <File Id="Microsoft.Owin.Host.HttpListener.dll" Name="Microsoft.Owin.Host.HttpListener.dll" Source="$(var.WixSetup2_TargetDir)Microsoft.Owin.Host.HttpListener.dll" />
      </Component>
      <Component Id="Microsoft.Owin.Diagnostics.dll" Guid="c5e44f7a-6961-4e9c-b2af-5d4a7e8d8b9d">
        <File Id="Microsoft.Owin.Diagnostics.dll" Name="Microsoft.Owin.Diagnostics.dll" Source="$(var.WixSetup2_TargetDir)Microsoft.Owin.Diagnostics.dll" />
      </Component>
    </ComponentGroup>
    <CustomAction Id="addPort" Directory="INSTALLFOLDER" Execute="immediate" Impersonate="no" ExeCommand="[SystemFolder]netsh.exe http add urlacl http://*:1919/ user=Everyone" Return="check">
    </CustomAction>
    <InstallExecuteSequence>
      <Custom Action="addPort" Before="InstallExecute">Installed</Custom>
    </InstallExecuteSequence>
  </Fragment>
  <Fragment>
    <ComponentGroup Id="ProgramFilesFolder_files" Directory="INSTALLFOLDER">
      <Component Id="Scripts_jquery_3.1.1.intellisense.js" Guid="e47264ab-facd-4c3b-9372-69e2f972fb44">
        <File Id="Scripts_jquery_3.1.1.intellisense.js" Name="jquery-3.1.1.intellisense.js" Source="$(var.WixSetup2_TargetDir)Scripts\jquery-3.1.1.intellisense.js" />
      </Component>
      <Component Id="Scripts_jquery_3.1.1.js" Guid="b51ca2fd-3c8a-461e-8340-e26b90dbeb4c">
        <File Id="Scripts_jquery_3.1.1.js" Name="jquery-3.1.1.js" Source="$(var.WixSetup2_TargetDir)Scripts\jquery-3.1.1.js" />
      </Component>
      <Component Id="Scripts_jquery_3.1.1.min.js" Guid="df63a174-bf0e-40ca-b634-aac1a9777afa">
        <File Id="Scripts_jquery_3.1.1.min.js" Name="jquery-3.1.1.min.js" Source="$(var.WixSetup2_TargetDir)Scripts\jquery-3.1.1.min.js" />
      </Component>
      <Component Id="Scripts_jquery_3.1.1.slim.js" Guid="63ddd1f4-b695-4441-8ce2-f81473069868">
        <File Id="Scripts_jquery_3.1.1.slim.js" Name="jquery-3.1.1.slim.js" Source="$(var.WixSetup2_TargetDir)Scripts\jquery-3.1.1.slim.js" />
      </Component>
      <Component Id="Scripts_jquery_3.1.1.slim.min.js" Guid="15b3bc22-b845-4d65-9c4b-baf654959531">
        <File Id="Scripts_jquery_3.1.1.slim.min.js" Name="jquery-3.1.1.slim.min.js" Source="$(var.WixSetup2_TargetDir)Scripts\jquery-3.1.1.slim.min.js" />
      </Component>
      <Component Id="Scripts_jquery.signalR_2.2.1.js" Guid="915b874f-398a-4e9e-af24-e68045ffca71">
        <File Id="Scripts_jquery.signalR_2.2.1.js" Name="jquery.signalR-2.2.1.js" Source="$(var.WixSetup2_TargetDir)Scripts\jquery.signalR-2.2.1.js" />
      </Component>
      <Component Id="Scripts_jquery.signalR_2.2.1.min.js" Guid="085dd028-262d-47b1-9b48-fc19d8e3db87">
        <File Id="Scripts_jquery.signalR_2.2.1.min.js" Name="jquery.signalR-2.2.1.min.js" Source="$(var.WixSetup2_TargetDir)Scripts\jquery.signalR-2.2.1.min.js" />
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>
&#13;
&#13;
&#13;

如果你能帮助我摆脱这个问题,那就太好了。

1 个答案:

答案 0 :(得分:2)

您已将条件设置为仅在已安装产品时运行。

将自定义操作中的条件更改为“未安装”。

<Custom Action="addPort" Before="InstallExecute">NOT Installed</Custom>