2017-09-18 28 views
1

將文件伴侶製作爲另一個文件的正確語法是什麼?我搜索了很多,但除了理論之外找不到多少東西。如何在wix安裝程序中將config.exe文件作爲其exe文件的伴隨文件

我的用例是我在某些服務中更新了.Net版本,現在我也正在更新安裝程序。目前,這是正在使用的辦法:

<Component Id="cmp123" Guid="{guid1}"> 
       <File Id="fileid1" KeyPath="yes" Source="$(var.Dir1)\Service1.exe" />     
       <ServiceInstall Id="ServiceInstall1" 
           Type="ownProcess" 
           Name="SCService1" 
           DisplayName="SCService1" 
           Description="SCService1" 
           Start="auto" 
           Account="NT Authority\NetworkService" 
           ErrorControl="normal" 
           Vital="yes" > 
       <util:ServiceConfig FirstFailureActionType="restart" SecondFailureActionType="restart" ThirdFailureActionType="none" ResetPeriodInDays="1" /> 
       <ServiceConfig DelayedAutoStart="yes" OnInstall="yes" OnReinstall="yes" /> 
       </ServiceInstall> 
       <ServiceControl Id="ServiceControlService1" Name="SCService1" Start="install" Stop="uninstall" Remove="uninstall" Wait="no" /> 
      </Component> 

      <Component Id="cmp456" Guid="{guid2}"> 
       <File Id="file2" KeyPath="yes" Source="$(var.Dir1)\Service1.exe.config" /> 
       <util:XmlFile Id="UpdateDotNetVersion" 
          File="[#file2]" 
          Action="setValue" 
          Name="sku" 
          Value=".NETFramework,Version=v4.6.2" 
          ElementPath="configurat/start/supportedRuntime" />     
      </Component> 

我想擺脫util:XmlFile,看看我能做出這樣的配置文件中的exe的伴隨文件。

我嘗試了以下情況:

<Component Id="cmp123" Guid="{guid1}"> 
        <File Id="fileid1" KeyPath="yes" Source="$(var.Dir1)\Service1.exe" />     
        <ServiceInstall Id="ServiceInstall1" 
            Type="ownProcess" 
            Name="SCService1" 
            DisplayName="SCService1" 
            Description="SCService1" 
            Start="auto" 
            Account="NT Authority\NetworkService" 
            ErrorControl="normal" 
            Vital="yes" > 
        <util:ServiceConfig FirstFailureActionType="restart" SecondFailureActionType="restart" ThirdFailureActionType="none" ResetPeriodInDays="1" /> 
        <ServiceConfig DelayedAutoStart="yes" OnInstall="yes" OnReinstall="yes" /> 
        </ServiceInstall> 
        <ServiceControl Id="ServiceControlService1" Name="SCService1" Start="install" Stop="uninstall" Remove="uninstall" Wait="no" /> 
       </Component> 

       <Component Id="cmp456" Guid="{guid2}"> 
        <File Id="file2" KeyPath="yes" Source="$(var.Dir1)\Service1.exe.config" /> 
         <File CompanionFile="cmp123" /> 
       </Component> 

這是正確的嗎?還是必須將伴隨文件添加到.exe組件,而不是在單獨的組件中?請幫助我在這裏的語法。 謝謝!

回答

2

您可以使用配套文件是這樣的:

<Component Id="cmp456" Guid="{guid2}"> 
    <File Id="file2" Source="$(var.Dir1)\Service1.exe.config" CompanionFile="fileid1" />      
</Component> 
+0

感謝您的答覆。但是我無法將伴侶文件製作爲其組件關鍵路徑的文件。設置keypath = no應該有所幫助。另外,藉此,當我通過上述更改升級到此版本時,那些添加了伴隨文件的服務不會自動重新啓動。我應該如何讓他們重新啓動? – Atihska

+0

Oh yeah CompanionFile不能是KeyPath,因爲它使用了伴隨文件中的KeyPath。我將更新答案以刪除KeyPath。不是關於服務不開始。可能是由我以前從未使用過的'ServiceConfig'造成的。 –

+0

當我不使用伴侶文件時,它工作正常。相反,我在配置文件中使用util:xmlfile標籤並使用setvalue操作。我只是想避免我不得不在每次版本升級時加入。讓我知道如果你想要的代碼,我可以發佈它。 – Atihska

相關問題