简体   繁体   English

WiX安装程序和自定义操作

[英]WiX installer and custom actions

I have an application that is a not so simple Windows service (C#). 我有一个不太简单的Windows服务(C#)的应用程序。 I created an installer using Visual Studio 2008, which did the job of installing the service on the clients machine, but using the Visual Studio deployment project has 2 drawbacks: 我使用Visual Studio 2008创建了一个安装程序,它完成了在客户端计算机上安装服务的工作,但使用Visual Studio部署项目有两个缺点:

  1. I can't seem to get the installer to build using MSBuild (i've tried the DevEnv.exe method). 我似乎无法使用MSBuild构建安装程序(我已经尝试过DevEnv.exe方法)。 The service is a small piece of a much larger project, and I'd like the build of the MSI file to happen at the same time as my build does. 该服务是一个更大的项目的一小部分,我希望MSI文件的构建与我的构建同时发生。 I have used WiX for the other installers, but this particular application requires a configuration step in the setup. 我已将WiX用于其他安装程序,但此特定应用程序需要在设置中进行配置步骤。
  2. There seems to be a bug in VS 2008's deployment project when installing windows services. 安装Windows服务时,VS 2008的部署项目似乎存在错误。 On repair and upgrade, the service is never stopped. 在修复和升级时,服务永远不会停止。 (caused by an invalid sequence for RemoveExistingProducts - i have worked around this by changing the sequence to 1525) (由RemoveExistingProducts的无效序列引起 - 我通过将序列更改为1525来解决此问题)

What is nice about VS2008's deployment project is that I created a custom action that shows a form that gets some info from the user, connects to a WCF service, which retrieves data and stores it in an encrypted data store on their local machine for use by the service. VS2008部署项目的优点在于我创建了一个自定义操作,显示一个表单,该表单从用户获取一些信息,连接到WCF服务,该服务检索数据并将其存储在本地计算机上的加密数据存储中以供服务。

Now, I have looked high and low, and I don't see this being possible with WiX. 现在,我看起来又高又低,我不认为这可能与WiX有关。 Running an EXE after the program has installed isn't 'nice'. 程序安装后运行EXE并不“好”。 I'd like to be able to call a method in my Custom Action DLL that displays the form, and does the processing it needs to. 我希望能够在我的自定义操作DLL中调用一个显示表单的方法,并进行所需的处理。 Is there any way of doing this with WiX? 有没有办法用WiX做到这一点? -- or even, create a custom GUI in WiX that gets the values and passes these values to a method for processing - 甚至在WiX中创建一个自定义GUI,获取值并将这些值传递给方法进行处理

So, questions: 所以,问题:

  1. Is this possible with WiX? 这可能与WiX有关吗?
  2. What are my alternatives if not? 如果不是,我有什么选择?

Many thanks 非常感谢

You can definitely install and start services with WiX - I'm doing that all day, every day :-) 你绝对可以使用WiX安装和启动服务 - 我每天都在这样做,每天:-)

Check out the ServiceInstall and ServiceControl elements (there are even more, if you need to specify even more). 查看ServiceInstallServiceControl元素(如果您需要指定甚至更多,还有更多元素)。

Basically, you need to first define your service file (YourService.exe) as a file in a component, and then you need to specify the ServiceInstall (and possibly ServiecControl) elements in addition to that. 基本上,您需要首先将服务文件(YourService.exe)定义为组件中的文件,然后除此之外还需要指定ServiceInstall(以及可能的ServiecControl)元素。

<Component Id='YourServiceComponent' Guid='.....' DiskId='1'>
  <File Id='YourServiceEXEFile' Name='YourService.exe' 
        src='(path to your EXE)/YourService.exe' KeyPath='yes'/>
  <ServiceInstall Id='YourServiceInstall' Name='YourServiceName' 
                  Description='.....' ErrorControl='normal' 
                  Start='auto' Type='ownProcess' Vital='yes' />
  <ServiceControl Id='UninstallYourService' Name='YourServiceName' 
                  Remove='uninstall' Wait='yes' />
</Component>

Then you need to add this component to one of the features in your install that's being installed - and that's about it! 然后,您需要将此组件添加到正在安装的安装中的某个功能 - 这就是它!

Marc

The answer to your question #1 is yes, but it's a little involved. 问题#1的答案是肯定的,但它有点牵扯。 You can define dialogs to collect info from the user with the UI element and store it session properties. 您可以定义对话框以使用UI元素从用户收集信息并存储其会话属性。 You can insert these dialogs into the flow with the Publish element . 您可以使用Publish元素将这些对话框插入到流中。 You can then create a vb script CustomAction and do just about anything with those session properties. 然后,您可以创建一个vb脚本CustomAction,并使用这些会话属性执行任何操作。 Check out this tutorial for more. 查看本教程了解更多信息。

Note about the WiX Service control node: 关于WiX服务控制节点的注意事项:

If you service relies on assemblies that your installer is putting in the GAC then it will fail to start. 如果您的服务依赖于安装程序在GAC中放置的程序集,那么它将无法启动。 For some reason WiX schedules the StartService action BEFORE it publishes assemblies to the GAC, so if this is the case you will need to write a custom action to start the service. 出于某种原因,WiX会在将程序集发布到GAC之前调度StartService操作,因此如果是这种情况,则需要编写自定义操作来启动该服务。

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

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