Hi,
I understand Topshelf netcore2 support is still in developing. I created a simple Topshelf netcore2 service like below.
class Program
{
static void Main(string[] args)
{
var containerBuilder = new ContainerBuilder();
containerBuilder.RegisterType<ShellService>();
var container = containerBuilder.Build();
HostFactory.Run(configurator =>
{
configurator.UseAutofacContainer(container);
configurator.Service<ShellService>(settings =>
{
settings.ConstructUsingAutofacContainer();
settings.WhenStarted(service => service.Start());
settings.WhenStopped(service => service.Stop());
}
);
configurator.SetDescription("Shell Service");
configurator.SetDisplayName("Shell Service");
configurator.SetServiceName("Shell Service");
});
}
}
Then I tried to install the service with an Admin console.
dotnet Nike.Service.Shell.dll install
The error I got was like below.
Topshelf.HostFactory Error: 0 : An exception occurred creating the host, Topshelf.HostConfigurationException: The service was not properly configured:
[Failure] Command Line An unknown command-line option was found: ARGUMENT: install
[Success] Name Shell Service
[Success] ServiceName Shell Service
at Topshelf.Configurators.ValidateConfigurationResult.CompileResults(IEnumerable`1 results)
at Topshelf.HostFactory.New(Action`1 configureCallback)
Topshelf.HostFactory Error: 0 : The service terminated abnormally, Topshelf.HostConfigurationException: The service was not properly configured:
[Failure] Command Line An unknown command-line option was found: ARGUMENT: install
[Success] Name Shell Service
[Success] ServiceName Shell Service
at Topshelf.Configurators.ValidateConfigurationResult.CompileResults(IEnumerable`1 results)
at Topshelf.HostFactory.New(Action`1 configureCallback)
at Topshelf.HostFactory.Run(Action`1 configureCallback)
Thanks,
David