我有一个项目,其中包括 2 个 Windows 服务。我创建了一个 ProjectInstaller 来安装这些项目,效果很好。但我有一个问题;鉴于下面定义的代码,项目安装程序如何知道要为 serviceInstaller1 安装哪个服务以及为 serviceInstaller2 安装哪个服务?
它只是基于ServiceName吗?
[RunInstaller(true)]
public partial class ProjectInstaller : System.Configuration.Install.Installer
{
private ServiceProcessInstaller process;
private ServiceInstaller serviceInstaller1;
private ServiceInstaller serviceInstaller2;
public ProjectInstaller()
{
InitializeComponent();
try
{
process = new ServiceProcessInstaller();
process.Account = ServiceAccount.LocalSystem;
serviceInstaller1 = new ServiceInstaller();
serviceInstaller1.ServiceName = "xxx";
serviceInstaller1.Description = "Does Something";
serviceInstaller1.StartType = ServiceStartMode.Automatic;
serviceInstaller2 = new ServiceInstaller();
serviceInstaller2.ServiceName = "yyy";
serviceInstaller2.Description = "Does something else";
serviceInstaller2.StartType = ServiceStartMode.Automatic;
Installers.Add(process);
Installers.Add(serviceInstaller1);
Installers.Add(serviceInstaller2);
}
catch (Exception ex)
{
throw new Exception("Failed", ex);
}
}
}