{"id":18426333,"url":"https://github.com/jordicorbilla/windowsservicehost","last_synced_at":"2025-04-13T18:54:08.789Z","repository":{"id":74791696,"uuid":"313390152","full_name":"JordiCorbilla/WindowsServiceHost","owner":"JordiCorbilla","description":"Hosting a .NET 5 webAPI in a Windows Service","archived":false,"fork":false,"pushed_at":"2020-12-12T08:36:31.000Z","size":63,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-16T08:26:33.413Z","etag":null,"topics":["csharp","https","net5","webapi","windowsservices"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JordiCorbilla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-16T18:21:30.000Z","updated_at":"2022-11-11T07:09:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"5792ae1b-37da-4660-b43c-9688f630040d","html_url":"https://github.com/JordiCorbilla/WindowsServiceHost","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JordiCorbilla%2FWindowsServiceHost","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JordiCorbilla%2FWindowsServiceHost/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JordiCorbilla%2FWindowsServiceHost/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JordiCorbilla%2FWindowsServiceHost/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JordiCorbilla","download_url":"https://codeload.github.com/JordiCorbilla/WindowsServiceHost/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248766251,"owners_count":21158297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","https","net5","webapi","windowsservices"],"created_at":"2024-11-06T05:07:41.165Z","updated_at":"2025-04-13T18:54:08.765Z","avatar_url":"https://github.com/JordiCorbilla.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Windows Service Host\n\n**Hosting a .NET 5 WebAPI in a Windows Service**\n\nThis project serves as a template to scaffold your Swagger Web API projects using .net 5 and hosting it in a Windows Service. As it's built using only .net 5, you can launch the project locally on IIS Express, as a command line tool or as a windows service. Using the windows service approach will let you host it on your server without having to use IIS.\n\n### Create the service\n\n```powershell\nC:\\\u003esc create HostedService binpath=C:\\WindowsServiceHostTemplate\\bin\\Debug\\net5.0\\WindowsServiceHostTemplate.exe\n[SC] CreateService SUCCESS\n\nC:\\WINDOWS\\system32\u003esc start HostedService\n```\n\n### Starting the solution as a console app\n\nYou can run the application as a simple console app and see the same results:\n\n```powershell\nC:\\WindowsServiceHostTemplate\\bin\\Debug\\net5.0\u003eWindowsServiceHostTemplate.exe\ninfo: WindowsServiceHostTemplate.Worker[0]\n      Worker running at: 11/18/2020 20:18:42 +00:00\n[20:18:42 INF] Starting...\ninfo: WindowsServiceHostTemplate.Worker[0]\n      Worker running at: 11/18/2020 20:18:43 +00:00\n[20:18:43 INF] Worker running at: 11/18/2020 20:18:43 +00:00\ninfo: WindowsServiceHostTemplate.Worker[0]\n      Worker running at: 11/18/2020 20:18:44 +00:00\n[20:18:44 INF] Worker running at: 11/18/2020 20:18:44 +00:00\n[info20:18:44: Microsoft.Hosting.Lifetime[0]\n      Now listening on: http://localhost:5000\n INF] Now listening on: http://localhost:5000\n[info: Microsoft.Hosting.Lifetime[0]\n      Now listening on: https://localhost:5001\n20:18:44 INF] Now listening on: https://localhost:5001\n[info: Microsoft.Hosting.Lifetime[0]\n      Application started. Press Ctrl+C to shut down.\n20:18:44 INF] Application started. Press Ctrl+C to shut down.\n[info20:18:44: Microsoft.Hosting.Lifetime[0]\n      Hosting environment: Production\n INF] Hosting environment: Production\n[info20:18:44: Microsoft.Hosting.Lifetime[0]\n      Content root path: C:\\WindowsServiceHostTemplate\\bin\\Debug\\net5.0\n INF] Content root path: C:\\WindowsServiceHostTemplate\\bin\\Debug\\net5.0\ninfo[: WindowsServiceHostTemplate.Worker[0]\n      Worker running at: 11/18/2020 20:18:45 +00:00\n20:18:45 INF] Worker running at: 11/18/2020 20:18:45 +00:00\n[info20:18:46: WindowsServiceHostTemplate.Worker[0]\n      Worker running at: 11/18/2020 20:18:46 +00:00\n INF] Worker running at: 11/18/2020 20:18:46 +00:00\ninfo[: WindowsServiceHostTemplate.Worker[0]\n      Worker running at: 11/18/2020 20:18:47 +00:00\n```\n\n### Navigate to the API\n\nOnce the application is running, navigate here -\u003e \u003chttps://localhost:5001/api/weatherforecast\u003e and you'll see the data.\n\nAnd also here for the Swagger API -\u003e \u003chttps://localhost:5001/swagger/api/index.html\u003e\n\n![apisample](apisample.png)\n\n### Packages Used\n\n```xml\n\u003cPackageReference Include=\"Serilog\" Version=\"2.10.0\" /\u003e\n\u003cPackageReference Include=\"Swashbuckle.AspNetCore\" Version=\"5.6.3\" /\u003e\n\u003cPackageReference Include=\"Swashbuckle.AspNetCore.Annotations\" Version=\"5.6.3\" /\u003e\n\u003cPackageReference Include=\"Microsoft.Extensions.Hosting.WindowsServices\" Version=\"5.0.0\" /\u003e\n\u003cPackageReference Include=\"Serilog.AspNetCore\" Version=\"3.4.0\" /\u003e\n\u003cPackageReference Include=\"Serilog.Sinks.Console\" Version=\"3.1.1\" /\u003e\n\u003cPackageReference Include=\"Swashbuckle.AspNetCore.Swagger\" Version=\"5.6.3\" /\u003e\n\u003cPackageReference Include=\"Microsoft.AspNetCore.Mvc.NewtonsoftJson\" Version=\"5.0.0\" /\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjordicorbilla%2Fwindowsservicehost","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjordicorbilla%2Fwindowsservicehost","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjordicorbilla%2Fwindowsservicehost/lists"}