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组件,而不是在单独的组件中?请帮助我在这里的语法。 谢谢!
感谢您的答复。但是我无法将伴侣文件制作为其组件关键路径的文件。设置keypath = no应该有所帮助。另外,借此,当我通过上述更改升级到此版本时,那些添加了伴随文件的服务不会自动重新启动。我应该如何让他们重新启动? – Atihska
Oh yeah CompanionFile不能是KeyPath,因为它使用了伴随文件中的KeyPath。我将更新答案以删除KeyPath。不是关于服务不开始。可能是由我以前从未使用过的'ServiceConfig'造成的。 –
当我不使用伴侣文件时,它工作正常。相反,我在配置文件中使用util:xmlfile标签并使用setvalue操作。我只是想避免我不得不在每次版本升级时加入。让我知道如果你想要的代码,我可以发布它。 – Atihska