Get running on `dotnet` cli / .NET Core #277

Open
TravisTheTechie opened this Issue Feb 5, 2016 · 29 comments

Comments

Projects
None yet
@TravisTheTechie
Contributor

TravisTheTechie commented Feb 5, 2016

dotnet cli will likely be the best bet for building cross platform executables moving forward. Once the API surface has settles down we can take a look at porting everything to do that, likely in additional to the existing supported platform versions.

@TravisTheTechie

This comment has been minimized.

Show comment
Hide comment
@TravisTheTechie

TravisTheTechie Feb 11, 2016

Contributor

I took a quick stab at this. Current issues...

  • Service installer isn't exposed at part of core
  • All our reflection bits have to be rewritten or shimmed
  • Diagnostics packages appear to have changed (unclear by how much yet)
  • System.ServiceProcess is missing ServiceAccount
  • AppDomains are bye-bye -- how do we handle unhandled exceptions?
  • No serializable (might just be able to remove, hold over from 2.0 days?)
  • Microsoft.Win32.Registry wasn't updated in last release, will it be missing from the core surface area?
  • Win32 interop stuff (e.g. SafeTokenHandle, NativeMethods) will likely need a rewrite

So I expect this will happen some day, but as of right now there wouldn't be feature parity between a .NET 4.5 and a .NET Core version. Some of these things might be resolved as the .NET team gets Core closer to release.

Contributor

TravisTheTechie commented Feb 11, 2016

I took a quick stab at this. Current issues...

  • Service installer isn't exposed at part of core
  • All our reflection bits have to be rewritten or shimmed
  • Diagnostics packages appear to have changed (unclear by how much yet)
  • System.ServiceProcess is missing ServiceAccount
  • AppDomains are bye-bye -- how do we handle unhandled exceptions?
  • No serializable (might just be able to remove, hold over from 2.0 days?)
  • Microsoft.Win32.Registry wasn't updated in last release, will it be missing from the core surface area?
  • Win32 interop stuff (e.g. SafeTokenHandle, NativeMethods) will likely need a rewrite

So I expect this will happen some day, but as of right now there wouldn't be feature parity between a .NET 4.5 and a .NET Core version. Some of these things might be resolved as the .NET team gets Core closer to release.

@phatboyg

This comment has been minimized.

Show comment
Hide comment
@phatboyg

phatboyg Feb 12, 2016

Contributor

Rock on, great work Travis. I suspected that the bridge might be difficult to cross.

Contributor

phatboyg commented Feb 12, 2016

Rock on, great work Travis. I suspected that the bridge might be difficult to cross.

@TravisTheTechie TravisTheTechie changed the title from Get running on `dotnet` cli to Get running on `dotnet` cli / .NET Core Mar 29, 2016

@dls314 dls314 referenced this issue in MassTransit/MassTransit Mar 29, 2016

Closed

.NET Core 2.0 Release Master Issue #527

@waynebrantley

This comment has been minimized.

Show comment
Hide comment
@waynebrantley

waynebrantley Mar 29, 2016

@jeremymeng Would you have any insight on the current outstanding issues?

@jeremymeng Would you have any insight on the current outstanding issues?

@TravisTheTechie

This comment has been minimized.

Show comment
Hide comment
@TravisTheTechie

TravisTheTechie Mar 29, 2016

Contributor

I had some conversations with @terrajobst on this, and the ServiceBase will likely not be exposed. We would need to rebuild the service installer on Core to allow post hooks, or rework things totally. WiX was the suggested alternative, which doesn't really solve the same problem (but does allow installation of services).

Contributor

TravisTheTechie commented Mar 29, 2016

I had some conversations with @terrajobst on this, and the ServiceBase will likely not be exposed. We would need to rebuild the service installer on Core to allow post hooks, or rework things totally. WiX was the suggested alternative, which doesn't really solve the same problem (but does allow installation of services).

@TravisTheTechie

This comment has been minimized.

Show comment
Hide comment
@TravisTheTechie

TravisTheTechie Apr 16, 2016

Contributor

@artganify sadly, Microsoft.AspNetCore.Hosting.WindowsService does not target .NET Core ~ see https://github.com/aspnet/Hosting/blob/dev/src/Microsoft.AspNetCore.Hosting.WindowsServices/project.json#L18

But if that changes, I'm happy to take another stab at this. We might be able to do it with a ".NET Core" which is just the .NET Core supported Console apps, then you have to import "Topshelf.WindowsService" or "Topshelf.Inetd" (or whatever) to support the platform you need. And Topshelf.WindowsService would only support .NET 4.5.2+, not the .NET Core platform. With netstandard coming, I hope we can do that 100% without retargeting any code for platforms. As it stands right now, it would require different assemblies for different platforms since the API surface area isn't 100% shared.

Contributor

TravisTheTechie commented Apr 16, 2016

@artganify sadly, Microsoft.AspNetCore.Hosting.WindowsService does not target .NET Core ~ see https://github.com/aspnet/Hosting/blob/dev/src/Microsoft.AspNetCore.Hosting.WindowsServices/project.json#L18

But if that changes, I'm happy to take another stab at this. We might be able to do it with a ".NET Core" which is just the .NET Core supported Console apps, then you have to import "Topshelf.WindowsService" or "Topshelf.Inetd" (or whatever) to support the platform you need. And Topshelf.WindowsService would only support .NET 4.5.2+, not the .NET Core platform. With netstandard coming, I hope we can do that 100% without retargeting any code for platforms. As it stands right now, it would require different assemblies for different platforms since the API surface area isn't 100% shared.

@liquidboy

This comment has been minimized.

Show comment
Hide comment
@liquidboy

liquidboy May 3, 2016

Hi Travis.. so judging by your comment on the 30th "we would need to rebuild the service installer ... rework things totally .." a .NET Core version is a very long way away ?

Am tempted to take a stab at investigating the effort BUT if you've already done the research ill probably look elsewhere for a .NET Core service wrapper (that works xplat too) ..

liquidboy commented May 3, 2016

Hi Travis.. so judging by your comment on the 30th "we would need to rebuild the service installer ... rework things totally .." a .NET Core version is a very long way away ?

Am tempted to take a stab at investigating the effort BUT if you've already done the research ill probably look elsewhere for a .NET Core service wrapper (that works xplat too) ..

@TravisTheTechie

This comment has been minimized.

Show comment
Hide comment
@TravisTheTechie

TravisTheTechie May 3, 2016

Contributor

I think we'll wait until .NET Core is not in flux any more. There's still a lot of movement on the APIs. So... if you want something before then, you're best looking elsewhere. It will happen, but when it happens depends on other stuff happening first.

I hope it's not "very long way away" but I can't make any promises at this point.

Contributor

TravisTheTechie commented May 3, 2016

I think we'll wait until .NET Core is not in flux any more. There's still a lot of movement on the APIs. So... if you want something before then, you're best looking elsewhere. It will happen, but when it happens depends on other stuff happening first.

I hope it's not "very long way away" but I can't make any promises at this point.

@israelito3000

This comment has been minimized.

Show comment
Hide comment
@israelito3000

israelito3000 Jun 28, 2016

Are we ready for this now?

Are we ready for this now?

@IanYates

This comment has been minimized.

Show comment
Hide comment
@IanYates

IanYates Jun 28, 2016

There's still no service installer, etc
See https://gist.github.com/davidfowl/8939f305567e1755412d6dc0b8baf1b7 for a great overview of the different netstandard levels and what's generally available.
INetStandard15 (in that document's context) would be the minimum as it supports assembly loading (mentioned as important earlier in this thread). But there's still no concept of Windows-only things like the registry and services. They'd need to be in a separate package. So that would require some TopShelf refactoring to have a netstandard-based app to do running as a console application or embedded as a service, and then the service hosting stuff would need to be in a separate desktop-level .NET package.
(just thinking out loud - sounds like a fair bit of work and definitely some breaking changes)

There's still no service installer, etc
See https://gist.github.com/davidfowl/8939f305567e1755412d6dc0b8baf1b7 for a great overview of the different netstandard levels and what's generally available.
INetStandard15 (in that document's context) would be the minimum as it supports assembly loading (mentioned as important earlier in this thread). But there's still no concept of Windows-only things like the registry and services. They'd need to be in a separate package. So that would require some TopShelf refactoring to have a netstandard-based app to do running as a console application or embedded as a service, and then the service hosting stuff would need to be in a separate desktop-level .NET package.
(just thinking out loud - sounds like a fair bit of work and definitely some breaking changes)

@TravisTheTechie

This comment has been minimized.

Show comment
Hide comment
@TravisTheTechie

TravisTheTechie Jun 29, 2016

Contributor

It is a major effort. So it's not likely to happen soon.

We can maybe shuffle how we do things to get there sooner, but it has limited value without ServiceBase since at the root it's just a console runner. I accept that it would enable us to offer other service platforms -- but that's not a priority of any of the maintainers at the moment.

Contributor

TravisTheTechie commented Jun 29, 2016

It is a major effort. So it's not likely to happen soon.

We can maybe shuffle how we do things to get there sooner, but it has limited value without ServiceBase since at the root it's just a console runner. I accept that it would enable us to offer other service platforms -- but that's not a priority of any of the maintainers at the moment.

@msnelling

This comment has been minimized.

Show comment
Hide comment
@msnelling

msnelling Jul 22, 2016

TopShelf is one of our cornerstone support packages and it would be great if it supported .Net Core. We are planning on moving our code base to the new framework, the last packages missing are TopShelf, RabbitMQ.Net and Google.ProtocolBuffers (although this has been merged into google/protobuf which is close to supporting .Net Core).
Also I believe that .Net Core has already hit 1.0.0 so I would expect the API to much more settled, though who knows with Microsoft!

msnelling commented Jul 22, 2016

TopShelf is one of our cornerstone support packages and it would be great if it supported .Net Core. We are planning on moving our code base to the new framework, the last packages missing are TopShelf, RabbitMQ.Net and Google.ProtocolBuffers (although this has been merged into google/protobuf which is close to supporting .Net Core).
Also I believe that .Net Core has already hit 1.0.0 so I would expect the API to much more settled, though who knows with Microsoft!

@Deilan

This comment has been minimized.

Show comment
Hide comment
@Deilan

Deilan Oct 18, 2016

This is definitely highly requested feature.

Deilan commented Oct 18, 2016

This is definitely highly requested feature.

@dasMulli

This comment has been minimized.

Show comment
Hide comment
@dasMulli

dasMulli Oct 31, 2016

@TravisTheTechie I recently needed to deal with missing ServiceBase support myself, so i cerated an alternative that directly uses the necessary interop calls. Also made a CreateService(...) and DeleteService(...) on the way. https://github.com/dasMulli/dotnet-win32-service
Maybe that helps..
Also runs nicely on nano server.

@TravisTheTechie I recently needed to deal with missing ServiceBase support myself, so i cerated an alternative that directly uses the necessary interop calls. Also made a CreateService(...) and DeleteService(...) on the way. https://github.com/dasMulli/dotnet-win32-service
Maybe that helps..
Also runs nicely on nano server.

@TravisTheTechie

This comment has been minimized.

Show comment
Hide comment
@TravisTheTechie

TravisTheTechie Nov 7, 2016

Contributor

The direction I understand is that more of the surface area is appearing in .NET Standard 2.0 and this will likely wait until that's delivered so we don't have to rewrite much, possibly breaking existing/working functionality.

Contributor

TravisTheTechie commented Nov 7, 2016

The direction I understand is that more of the surface area is appearing in .NET Standard 2.0 and this will likely wait until that's delivered so we don't have to rewrite much, possibly breaking existing/working functionality.

@thangchung

This comment has been minimized.

Show comment
Hide comment
@thangchung

thangchung Jan 25, 2017

@TravisTheTechie Just waiting for that. Some of my projects are still not dared to do a porting into .NET Core because of this reason.

@TravisTheTechie Just waiting for that. Some of my projects are still not dared to do a porting into .NET Core because of this reason.

@TravisTheTechie

This comment has been minimized.

Show comment
Hide comment
@TravisTheTechie

TravisTheTechie Feb 8, 2017

Contributor

I'm closing this issue to show we're taking no action on it at this time. Can reopen or create a new one once things are settled.

Contributor

TravisTheTechie commented Feb 8, 2017

I'm closing this issue to show we're taking no action on it at this time. Can reopen or create a new one once things are settled.

@ForNeVeR

This comment has been minimized.

Show comment
Hide comment
@ForNeVeR

ForNeVeR Apr 26, 2017

Well, should we reopen this finally?

Well, should we reopen this finally?

@xclayl

This comment has been minimized.

Show comment
Hide comment
@xclayl

xclayl May 3, 2017

What about this? https://github.com/dasMulli/dotnet-win32-service
Personally I really like TopShelf, but they seem to have a Windows Service for .Net Core.

xclayl commented May 3, 2017

What about this? https://github.com/dasMulli/dotnet-win32-service
Personally I really like TopShelf, but they seem to have a Windows Service for .Net Core.

@andymac4182

This comment has been minimized.

Show comment
Hide comment
@andymac4182

andymac4182 May 3, 2017

.NET Core 2.0 is adding in the apis to make this work as part of the library I believe. I am using https://github.com/PeterKottas/DotNetCore.WindowsService currently for one of my services.

.NET Core 2.0 is adding in the apis to make this work as part of the library I believe. I am using https://github.com/PeterKottas/DotNetCore.WindowsService currently for one of my services.

@phatboyg phatboyg reopened this May 3, 2017

@phatboyg

This comment has been minimized.

Show comment
Hide comment
@phatboyg

phatboyg May 3, 2017

Contributor

Yes, we should open this and get it working with .NET Core, as we update the entire MT stack to support CORE.

Contributor

phatboyg commented May 3, 2017

Yes, we should open this and get it working with .NET Core, as we update the entire MT stack to support CORE.

@dasMulli

This comment has been minimized.

Show comment
Hide comment
@dasMulli

dasMulli May 3, 2017

.NET Core 2.0 is adding in the apis to make this work

Doesn't look like it, dotnet/corefx#6024 is still in "Future". Or am i missing something obvious @andymac4182 ?

The lib i've written (https://github.com/dasMulli/dotnet-win32-service) makes the necessary interop calls directly via PInvokes (ServiceBase doesn't do anything different..) and has a very simple state handling model (you can write a custom state machine if you need additional commands like pause/resume or special fancy events like power / network changes). It also doesn't work with InstallUtil.exe but exposes APIs to register/unregister (update coming soon) windows service registrations.
Since this really is only a basic API layer (like ServiceBase is), @PeterKottas wrote a layer on top of it to get an API that more resembles TopShelf.

Given the current .NET Core 2.0 API shape, TopShelf could either implement the interop calls itself or take a dependency on DasMulli.Win32.ServiceUtils (or copy the necessary files, they are just MIT licensed) to replace dependencies on ServiceBase (it's not a drop-in replacement though).
Happy to provide help and guidance if necessary.

dasMulli commented May 3, 2017

.NET Core 2.0 is adding in the apis to make this work

Doesn't look like it, dotnet/corefx#6024 is still in "Future". Or am i missing something obvious @andymac4182 ?

The lib i've written (https://github.com/dasMulli/dotnet-win32-service) makes the necessary interop calls directly via PInvokes (ServiceBase doesn't do anything different..) and has a very simple state handling model (you can write a custom state machine if you need additional commands like pause/resume or special fancy events like power / network changes). It also doesn't work with InstallUtil.exe but exposes APIs to register/unregister (update coming soon) windows service registrations.
Since this really is only a basic API layer (like ServiceBase is), @PeterKottas wrote a layer on top of it to get an API that more resembles TopShelf.

Given the current .NET Core 2.0 API shape, TopShelf could either implement the interop calls itself or take a dependency on DasMulli.Win32.ServiceUtils (or copy the necessary files, they are just MIT licensed) to replace dependencies on ServiceBase (it's not a drop-in replacement though).
Happy to provide help and guidance if necessary.

@alkampfergit

This comment has been minimized.

Show comment
Hide comment
@alkampfergit

alkampfergit Aug 16, 2017

Now that .NET Core 2 is out, is there any plan to porting topshelf on .NET core in the near future?

Now that .NET Core 2 is out, is there any plan to porting topshelf on .NET core in the near future?

@scottt732

This comment has been minimized.

Show comment
Hide comment
@scottt732

scottt732 Aug 19, 2017

@alkampfergit I'm not a contributor so take this with a grain of salt, but a proper solution is likely blocked by the following, which is slated for .NET Core 2.1 (Q4 2017 according to https://github.com/dotnet/core/blob/master/roadmap.md):

@alkampfergit I'm not a contributor so take this with a grain of salt, but a proper solution is likely blocked by the following, which is slated for .NET Core 2.1 (Q4 2017 according to https://github.com/dotnet/core/blob/master/roadmap.md):

@andymac4182

This comment has been minimized.

Show comment
Hide comment
@andymac4182

andymac4182 Aug 19, 2017

I am curious if this is required due to the new IHostedService coming to dotnet core. https://www.stevejgordon.co.uk/asp-net-core-2-ihostedservice

Haven't spent enough time on it yet to see if it can do all the same things as TopShelf.

I am curious if this is required due to the new IHostedService coming to dotnet core. https://www.stevejgordon.co.uk/asp-net-core-2-ihostedservice

Haven't spent enough time on it yet to see if it can do all the same things as TopShelf.

@KiransHub

This comment has been minimized.

Show comment
Hide comment
@KiransHub

KiransHub Aug 20, 2017

Are there any alternative libraries that I can use for this?

Are there any alternative libraries that I can use for this?

@dasMulli

This comment has been minimized.

Show comment
Hide comment
@dasMulli

dasMulli Aug 20, 2017

@KiransHub what's your need? there's my https://github.com/dasMulli/dotnet-win32-service for minimum support to get a windows service running with core.

@KiransHub what's your need? there's my https://github.com/dasMulli/dotnet-win32-service for minimum support to get a windows service running with core.

@PeterKottas

This comment has been minimized.

Show comment
Hide comment
@PeterKottas

PeterKottas Aug 22, 2017

@KiransHub also if you prefer Topshelf-like api feel free to check out https://github.com/PeterKottas/DotNetCore.WindowsService it uses @dasMulli s lib in the background and exposes an interface that I found slightly easier to use. Especially if you have experience with topshelf.

@KiransHub also if you prefer Topshelf-like api feel free to check out https://github.com/PeterKottas/DotNetCore.WindowsService it uses @dasMulli s lib in the background and exposes an interface that I found slightly easier to use. Especially if you have experience with topshelf.

@galvesribeiro

This comment has been minimized.

Show comment
Hide comment
@galvesribeiro

galvesribeiro Nov 20, 2017

@TravisTheTechie ServiceBase was merged. What is missing to follow this port?

@TravisTheTechie ServiceBase was merged. What is missing to follow this port?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment