-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UseWindowsService
does not work with WebApplicationBuilder
#69212
Comments
Related: dotnet/aspnetcore#37464 |
Triage: we could improve the message here to be more detailed about what specific option you'd need to set. |
Tagging subscribers to this area: @dotnet/area-extensions-hosting Issue DetailsIs there an existing issue for this?
Describe the bugIn ASP.NET Core 6, it is not possible to call Expected BehaviorThe default template for ASP.NET Core 6 should be possible to host in a Windows Service. Steps To ReproduceMinimal repro with template:
ASP.NET Core 6 Program.cs (not working):
ASP.NET Core 3.1 Program.cs (working):
Exceptions (if any)
.NET Version6.0.200 Anything else?Possible workaround (from here):
This workaround was enough for me but has not been extensively tested. The documentation does not address the newer APIs: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/windows-service?view=aspnetcore-6.0&tabs=visual-studio
|
Is there an existing issue for this?
Describe the bug
In ASP.NET Core 6, it is not possible to call
UseWindowsService()
when usingWebApplicationBuilder
. Doing so results in an exception.This affects any new projects created using the default template for ASP.NET Core 6.
Expected Behavior
The default template for ASP.NET Core 6 should be possible to host in a Windows Service.
Steps To Reproduce
Minimal repro with template:
dotnet new webapi -n winsvctest
dotnet add package Microsoft.Extensions.Hosting.WindowsServices
Program.cs
, add this at line 2:builder.Host.UseWindowsService();
dotnet publish -c Release
sc create winsvctest start=auto DisplayName="winsvctest" binPath="...\winsvctest.exe"
(enter the absolute path)sc start winsvctest
ASP.NET Core 6 Program.cs (not working):
ASP.NET Core 3.1 Program.cs (working):
Exceptions (if any)
.NET Version
6.0.200
Anything else?
Possible workaround (from here):
This workaround was enough for me but has not been extensively tested.
The documentation does not address the newer APIs: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/windows-service?view=aspnetcore-6.0&tabs=visual-studio
The text was updated successfully, but these errors were encountered: