C# Topshelf Windows服务安装从未完成
我有三个windows服务,都是使用TopShelf创建的。这三个项目的配置非常相似,所以我更新了我的三个项目,以使用共享框架类型的项目C# Topshelf Windows服务安装从未完成,c#,powershell,windows-services,topshelf,octopus,C#,Powershell,Windows Services,Topshelf,Octopus,我有三个windows服务,都是使用TopShelf创建的。这三个项目的配置非常相似,所以我更新了我的三个项目,以使用共享框架类型的项目 public void StartService() { HostFactory.New(x => { x.Service<IService>(s => { s.ConstructUsing(() =>_ser
public void StartService()
{
HostFactory.New(x =>
{
x.Service<IService>(s =>
{
s.ConstructUsing(() =>_service);
s.WhenStarted(poller => poller.Start());
s.WhenStopped(poller => poller.Stop());
});
x.EnableShutdown();
x.RunAsLocalSystem();
x.SetDescription(description);
x.SetDisplayName(display);
x.SetServiceName(name);
x.StartAutomatically();
x.OnException(ex =>
{
ExceptionManager.Publish(ex);
});
x.EnableServiceRecovery(rc =>
{
rc.RestartService(1);
rc.RestartService(1);
rc.RestartService(1);
});
}).Run();
}
public void StartService()
{
HostFactory.New(x=>
{
x、 服务(s=>
{
s、 使用(()=>\u服务)进行构造;
s、 开始时(poller=>poller.Start());
s、 停止时(poller=>poller.Stop());
});
x、 启用关机();
x、 RunAsLocalSystem();
x、 设置描述(描述);
x、 SetDisplayName(显示);
x、 SetServiceName(名称);
x、 StartAutomatically();
x、 OneException(ex=>
{
例外管理器发布(ex);
});
x、 启用ServiceRecovery(rc=>
{
rc.餐厅服务(1);
rc.餐厅服务(1);
rc.餐厅服务(1);
});
}).Run();
}
要部署这些服务,八达通中有一个步骤可以为每个服务运行。该步骤执行以下操作:(所有命令都使用powershell运行)