【发布时间】:2012-02-24 06:12:53
【问题描述】:
我正在尝试为我的 Windows 服务创建一个 msi 安装。创建 msi 的原因是目标用户希望能够在尽可能少的干预的情况下快速安装服务。
我可以将服务安装为 msi,但我的代码中有一个变量,我需要用户定义何时安装 msi。我需要用户的变量是他们希望我的服务创建的 xml 文件所在的文件路径。
我想我可以配置 app.config 应用程序设置以包含 xml 文件应写入的文件路径。但是我正在努力做到这一点,我不确定这是否是最好的方法?
我有我的安装项目,其中包含我的可执行文件,并且我的文本框将包含来自用户的一个变量。
我有一个安装程序类,其中包含我的服务安装程序和进程安装程序。这就是我努力理解下一步我需要做什么的地方。 我需要覆盖安装方法吗?我的安装程序类的当前代码是自动生成的,如下:
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 是我的变量名。
我在安装程序代码方面非常苦恼……我想?
【问题讨论】:
标签: vb.net windows-services windows-installer app-config