WiX安装程序中的Parameterise服务启动选项

Jam*_*iec 6 .net windows-services wix serviceinstall

我在WiX安装程序中有一个ServiceInstall组件,我要求根据传入MSI的参数启动auto或demand.

所以问题的Xml元素是

<ServiceInstall Vital="yes"
     Name="My Windows Service"
     Type="ownProcess"
     Account="[SERVICEUSERDOMAIN]\[SERVICEUSERNAME]"
     DisplayName="My Service"
     Password="[SERVICEUSERPASSWORD]"
     Start="demand"
     Interactive="no"
     Description="Something interesting here"
     Id="Service"
     ErrorControl="ignore"></ServiceInstall>
Run Code Online (Sandbox Code Playgroud)

WiX将不允许使用参数作为Start属性,因此我坚持完全使用条件来补充组件,例如/

<Component Id="ServiceDemand"
                 Guid="{E204A71D-B0EB-4af0-96DB-9823605050C7}" >
        <Condition>SERVICESTART="demand"</Condition>    
...
Run Code Online (Sandbox Code Playgroud)

并完全复制整个组件,具有不同的Start设置和不同的Condition.

谁知道更优雅的解决方案?一个我不知道的地方;除了开始的属性之外,我必须保持两个完全相同的组件吗?

Sco*_*ger 6

ServiceInstall表中的"开始"字段未格式化,因此您使用属性输入的内容将不起作用.此链接提供了一些有用的建议,可以帮助您完成它:ServiceInstall - Start元素.看起来发布的人有同样的问题.我最喜欢的建议是创建一个在InstallServices操作之前运行的自定义操作,它将更改Service Install表中Start元素的值.

更新:修改了建议网站的链接.