简体   繁体   English

Wix MSI包:用于Windows服务

[英]Wix MSI package : for Windows service

Error : Creating new installer using WiX toolset, for windows service. 错误:使用WiX工具集为Windows服务创建新的安装程序。 Not able to install the service. 无法安装该服务。 Getting an error 得到一个错误
Error screenshot 错误截图

Environment 环境

  • Microsoft visual studio 2017 微软视觉工作室2017
  • Windows 7 Windows 7的
  • WiX toolset v3 : Setup project for MSI WiX工具集v3:MSI的安装项目

Problem/Goal 问题/目标

I want to create a MSI which installs a Windows service. 我想创建一个安装Windows服务的MSI。

On Install : 安装时:

Windows service gets installed and visible in services.msc Windows服务已在services.msc中安装并可见

On UnInstall: 在UnInstall上:

Stop and Remove the service. 停止并删除该服务。

My windows service has lot of dependencies which are to be used when running the service. 我的Windows服务有很多依赖项,在运行服务时使用。

I have added all the files as component and added ServiceDependency for each of the component ID also, but still not able to resolve the error. 我已将所有文件添加为组件,并为每个组件ID添加了ServiceDependency ,但仍无法解决错误。 The error in the event viewer is also the same as the above screenshot. 事件查看器中的错误也与上面的屏幕截图相同。

Any pointers are most welcome. 任何指针都是最受欢迎的。

My Code 我的守则

    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <MediaTemplate EmbedCab="yes" />

    <Feature Id="ProductFeature" Title="LayoutSwitcher" Level="1">
        <ComponentGroupRef Id="ProductComponents" />
    </Feature>
</Product>

<Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLFOLDER" Name="LayoutSwitcher" />
        </Directory>
    </Directory>
</Fragment>

<Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">

  <Component Id="PlcmLayoutSwitcherWinSvc.exe" Guid="PUT_GUID_HERE" KeyPath="yes">
            <File Id="LayoutSwitcherWinSvc.exe" 
 Name="LayoutSwitcherWinSvc.exe" Source="$(var.LayoutSwitcherWinSvc_TargetDir)LayoutSwitcherWinSvc.exe" />

    <CreateFolder />
    <ServiceInstall Id="LayoutSwitcher" Type="ownProcess" Vital="yes" 
                    Name="LayoutSwitcher" DisplayName="LayoutSwitcher" 
                    Description="LayoutSwitcher" Start="auto" Account="NT AUTHORITY\LocalSystem" 
                    ErrorControl="ignore" Interactive="no">
   <ServiceControl Id="StartService" Start="install" Stop="both" 
    Remove="uninstall" Name="LayoutSwitcher" Wait="yes" />
  </Component>
    <Component Id="logoicon.ico" Guid="PUT_GUID_HERE">
        <File Id="logoicon.ico" Name="logoicon.ico" Source="$(var.LayoutSwitcherWinSvc_ProjectDir)logoicon.ico" />
     </Component>
     <Component Id="LayoutSwitcherWinSvc.exe.config" Guid="PUT_GUID_HERE">
     <File Id="LayoutSwitcherWinSvc.exe.config" Name="LayoutSwitcherWinSvc.exe.config" Source="$(var.LayoutSwitcherWinSvc_TargetDir)LayoutSwitcherWinSvc.exe.config" />
  </Component>
  <Component Id="Transactions.dll" Guid="PUT_GUID_HERE">
    <File Id="Transactions.dll" Name="Transactions.dll" Source="$(var.LayoutSwitcherWinSvc_TargetDir)Transactions.dll" />
  </Component>
  <Component Id="Transactions.Cfg.dll" Guid="PUT_GUID_HERE">
    <File Id=" Transactions.Cfg.dll" Name="Transactions.Cfg.dll" Source="$(var.LayoutSwitcherWinSvc_TargetDir) Transactions.Cfg.dll" />
  </Component>

EDIT :1 编辑:1

Updated the source code after removing the service dependency, but still getting the same error. 删除服务依赖项后更新了源代码,但仍然收到相同的错误。

EDIT :2 编辑:2

Removed the whitespaces, but still getting the same error. 删除了空格,但仍然得到相同的错误。

EDIT :3 编辑:3

Verbose logs attached. 附加了详细日志。 Please download from the below link. 请从以下链接下载。
http://www.yourfilelink.com/get.php?fid=1432133 http://www.yourfilelink.com/get.php?fid=1432133

Your ServiceDepenency elements appear to be listing the dlls and other files that your service's executable depends on. 您的ServiceDepenency元素似乎列出了服务可执行文件所依赖的dll和其他文件。 That is not the intention of the ServiceDependency element. 这不是ServiceDependency元素的用意。 It is supposed to list other services that must start before this service. 它应该列出必须在此服务之前启动的其他服务。 The error you receive is likely due to the fact that LayoutSwitcherWinSvc.exe.config and all the *.dll files you list others are not the names of services installed on the target machine. 您收到的错误可能是由于LayoutSwitcherWinSvc.exe.config和您列出的所有* .dll文件不是目标计算机上安装的服务的名称。

The fix is likely to remove these ServiceDependency elements. 该修复可能会删除这些ServiceDependency元素。 Then, only if your service depends on other services, add ServiceDependency elements for those services by name. 然后,仅当您的服务依赖于其他服务时,才按名称为这些服务添加ServiceDependency元素。


With that part solved, it appears your ServiceInstall and ServiceControl elements are still incorrect. 解决了该部分后,您的ServiceInstallServiceControl元素仍然不正确。 In particular, the Name attributes don't match. 特别是, Name属性不匹配。 In your example code, it appears you include leading whitespace in a lot of your elements, and I would remove that. 在您的示例代码中,您看起来在许多元素中包含前导空格,我会删除它。 But, even if that's just errata from copy and paste, the installed LayoutSwitcher differs from started Layout Switcher by some whitespace in the middle. 但是,即使这只是复制和粘贴的勘误,安装的LayoutSwitcher也不同于启动的布局切换器中间的一些空格。

This matches the error 0x80070424 you mentioned in the comment, as 0x424 = 1060, and net helpmsg 1060 reports: 这匹配您在评论中提到的错误0x80070424,如0x424 = 1060,以及net helpmsg 1060报告:

The specified service does not exist as an installed service. 指定的服务不作为已安装的服务存在。

Make sure that the ServiceInstall/@Name and ServiceControl/@Name attributes match what you used when manually starting the service. 确保ServiceInstall / @ NameServiceControl / @ Name属性与手动启动服务时使用的属性相匹配。 (Note that if your manual test was on the command line, it is strongly likely that any whitespace was implicitly removed.) (请注意,如果您的手动测试位于命令行中,则很可能会隐式删除任何空格。)

Try making both of the Name attributes exactly the same in the install and the control. 尝试在安装和控件中使两个Name属性完全相同。 They need to match exactly and they don't. 他们需要完全匹配,而不是。 You're trying to start a non-existent service. 您正在尝试启动不存在的服务。

Your message: 你的信息:

"Failed to store ACL rollback information with error 0x80070424;Error 0x80070424: failed to get security info for object;CustomAction ExecSecureObjects returned actual error code 1603" “无法存储错误0x80070424的ACL回滚信息;错误0x80070424:无法获取对象的安全信息; CustomAction ExecSecureObjects返回实际错误代码1603”

is nothing to do with the services. 与服务无关。 Ideally you should close this question because the service problem is resolved and you now have a separate problem, described by that error message. 理想情况下,您应该关闭此问题,因为服务问题已解决,您现在有一个单独的问题,由该错误消息描述。

Somehow you have managed to invoke a WiX custom action "ExecSecureObjects" that is nothing to do with your services. 不知何故,您已设法调用与您的服务无关的WiX自定义操作“ExecSecureObjects”。 Somewhere in your WiX you are trying to secure some objects with the PermissionEx from the WiX util extension. 在WiX的某处,您正尝试使用WiX util扩展中的PermissionEx来保护某些对象。 That is the issue you are now seeing. 这是你现在看到的问题。

Can you try this piece of wix code? 你能试试这段wix代码吗? I cleaned it a little bit to remove some default values. 我清理了一下以删除一些默认值。

Unless you want to place the file with a different filename you don't need the Name attribute. 除非您想使用不同的文件名放置文件,否则您不需要Name属性。

If you want your service to run as Local System then you need to set empty Account. 如果您希望您的服务作为本地系统运行,则需要设置空帐户。 If you want it to run as a specific user then you could set the properties on your command line SVCACCOUNT=someuser SVCPASSWORD="password", otherwise just skip them. 如果您希望它以特定用户身份运行,那么您可以在命令行上设置属性SVCACCOUNT = someuser SVCPASSWORD =“password”,否则只需跳过它们。

If Name and Id is the same then you can skip the Id. 如果Name和Id相同,则可以跳过Id。

I prefer to use variables for things that I use in multiple places to avoid typos, for example ServiceName that is used in ServiceInstall and ServiceControl I use: 我更喜欢将变量用于我在多个地方使用的东西,以避免拼写错误,例如ServiceInstall中使用的ServiceName和我使用的ServiceControl:

<WixVariable Id="ServiceName" Value="LayoutSwitcher" />

<Component Id="PlcmLayoutSwitcherWinSvc.exe" Guid="PUT_GUID_HERE">
  <File Id="LayoutSwitcherWinSvc.exe" Source="$(var.LayoutSwitcherWinSvc_TargetDir)LayoutSwitcherWinSvc.exe" KeyPath="yes" />
  <ServiceInstall Name="!(wix.ServiceName)"
                  DisplayName="LayoutSwitcher"
                  Description="LayoutSwitcher"
                  ErrorControl="ignore"
                  Type="ownProcess" 
                  Vital="yes"
                  Start="auto"
                  Account="[SVCACCOUNT]"
                  Password="[SVCPASSWORD]" 
                  Interactive="no" />
  <ServiceControl Id="ServiceControl_!(wix.ServiceName)"
                  Name="!(wix.ServiceName)"
                  Start="install"
                  Stop="both"
                  Remove="uninstall"
                  Wait="yes" />
</Component>

The log you attached is incomplete, run the installer all the way through and attach the log only after you've closed the installer. 您附加的日志不完整,一直运行安装程序并仅在关闭安装程序后附加日志。 IMO Debug log is not necessary. 不需要IMO调试日志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM