我正在尝试为我的Windows服务创建msi安装。创建msi的原因是,预期的用户希望能够尽可能少地进行干预来快速安装服务。在MSI安装期间配置App.config应用程序设置vb.net
我可以得到安装为msi的服务,但我的代码中有一个变量,我需要用户定义msi的安装时间。我从用户需要的变量是他们希望我的服务创建的xml文件位于的文件路径。
我想我可以配置app.config应用程序设置来包含xml文件应写入的文件路径。然而,我正在努力做到这一点,我不确定它是否是最好的方法呢?
我有我的安装项目,其中包含我的可执行文件,并有我的文本框将包含用户的一个变量。
我有一个安装程序类,其中包含我的serviceinstaller和进程安装程序。这就是我努力理解接下来要做什么的地方。 我是否需要重写安装方法?我安装程序类的当前的代码是自动生成的,如下:
Imports System.Configuration.Install
Imports System.Configuration
<System.ComponentModel.RunInstaller(True)> Partial Class ProjectInstaller
Inherits System.Configuration.Install.Installer
'Installer overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Component Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Component Designer
'It can be modified using the Component Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.ServiceProcessInstaller1 = New System.ServiceProcess.ServiceProcessInstaller()
Me.ServiceInstaller1 = New System.ServiceProcess.ServiceInstaller()
'
'ServiceProcessInstaller1
'
Me.ServiceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem
Me.ServiceProcessInstaller1.Password = Nothing
Me.ServiceProcessInstaller1.Username = Nothing
'
'ServiceInstaller1
'
Me.ServiceInstaller1.ServiceName = "Spotter"
Me.ServiceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic
'
'ProjectInstaller
'
Me.Installers.AddRange(New System.Configuration.Install.Installer() {Me.ServiceProcessInstaller1, Me.ServiceInstaller1})
End Sub
Friend WithEvents ServiceProcessInstaller1 As System.ServiceProcess.ServiceProcessInstaller
Friend WithEvents ServiceInstaller1 As System.ServiceProcess.ServiceInstaller
End Class
我甚至可以添加CustomActionData值。该字符串决定了传递到用于收集输入的用户值的上下文对象中的内容。 param1是我的变量名称。
我非常努力的安装程序代码...我想?
感谢您的回复。阅读你的榜样,努力完全理解它。什么是变量Me.XMLDir? – Simon 2012-02-01 22:02:21
该变量仅用于显示提取在customdata中传递的值。这是你将用来更新app.config。 – 2012-02-02 06:35:40