2017-02-27 65 views
0

首次安裝我試圖開發利用SingnalR應用程序將安裝到客戶端機器,不斷給我一個特定端口上進行更新。我使用WIX進行了客戶端設置,並添加了一個自定義事件來將端口註冊到客戶端計算機。現在的問題是,當我要在客戶端機器上首次運行安裝程序時,我的自定義事件並未被解僱。但是如果我第二次運行安裝程序,它會被解僱。我不知道是什麼問題。自定義事件不執行,同時使用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>

這將是巨大的,如果你能幫助我擺脫這個問題。

回答

2

您已將條件設置爲僅在產品已安裝時才運行。

將自定義操作中的條件更改爲未安裝。

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

它的工作原理。謝謝Arkady。 – Kendy

相關問題