如何在wix安装程序中使config.exe文件成为其exe的伴随文件

如何在wix安装程序中使config.exe文件成为其exe的伴随文件,wix,windows-installer,Wix,Windows Installer,使一个文件与另一个文件配对的正确语法是什么?我在谷歌上搜索了很多,但除了理论之外,找不到更多 我的用例是,我在一些服务中更新了.Net版本,现在我也在更新安装程序。目前,这是正在使用的方法: <Component Id="cmp123" Guid="{guid1}"> <File Id="fileid1" KeyPath="yes" Source="$(var.Dir1)\Service1.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>
这是正确的吗?或者我必须将配套文件添加到.exe组件而不是单独的组件中吗?请帮我理解这里的语法。
谢谢

您可以像这样使用配套文件:

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


谢谢您的回复。但我不能将伴生文件作为其组件的键路径。设置keypath=no应该会有所帮助。同样,当我使用上述更改升级到此版本时,那些添加了配套文件的服务不会自动重新启动。我应该如何让它们重新启动?哦,是的,CompanionFile不能是KeyPath,因为它使用的是伴随文件中的KeyPath。我将更新答案以删除KeyPath。不是关于服务没有启动。可能是因为
ServiceConfig
我以前从未使用过它。当我不使用配套文件时,它工作正常。相反,我在配置文件中使用util:xmlfile标记并使用setvalue操作。我只是想避免每次版本升级时都要添加的其他内容。让我知道,如果你想要代码,我可以发布它。
<Component Id="cmp456" Guid="{guid2}">
    <File Id="file2" Source="$(var.Dir1)\Service1.exe.config" CompanionFile="fileid1" />                      
</Component>