1

My question is regarding this documentation page: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-5.0&tabs=visual-studio

Which says:

An app created from the Worker Service template specifies the Worker SDK in its project file:

<Project Sdk="Microsoft.NET.Sdk.Worker">

The page then describes how to change the default pipeline config behavior:

To change the default behavior, add the hosted service (VideosWatcher in the following example) after calling ConfigureWebHostDefaults:

In this question, answer says:

Moreover it look like your project is a Console Application. That is the problem. ConfigureWebHostDefaults is for Web Application only. So you can convert your Console Application into Web Applicaton by replacing Sdk="Microsoft.NET.Sdk" with Sdk="Microsoft.NET.Sdk.Web" in your .csproj file

The error I am getting is

IHostBuilder does not contain a definition for ConfigureWebHostDefaults...

My specific question at this point is: Should I be able to use the worker service SDK as specified in the documentation and also call ConfigureWebHostDefaults as is also specified in the documentation? If so, how do I do that? I am referencing Microsoft.Extensions.Hosting and Microsoft.AspNetCore.Hosting packages.

1 Answers1

0

Of cource you can, just install the Microsoft.Extensions.Hosting.Abstractions package

dotnet add package Microsoft.Extensions.Hosting.Abstractions --version 5.0.0
Roman Marusyk
  • 23,328
  • 24
  • 73
  • 116