Skip to content

Commit

Permalink
Surface Worker Service project template (#12665)
Browse files Browse the repository at this point in the history
  • Loading branch information
guardrex authored Jun 4, 2019
1 parent 5c0f1c1 commit 80eacc4
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
28 changes: 27 additions & 1 deletion aspnetcore/fundamentals/host/hosted-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Learn how to implement background tasks with hosted services in ASP
monikerRange: '>= aspnetcore-2.1'
ms.author: riande
ms.custom: mvc
ms.date: 02/25/2019
ms.date: 06/03/2019
uid: fundamentals/host/hosted-services
---
# Background tasks with hosted services in ASP.NET Core
Expand All @@ -25,6 +25,32 @@ The sample app is provided in two versions:
* Web Host – Web Host is useful for hosting web apps. The example code shown in this topic is from Web Host version of the sample. For more information, see the [Web Host](xref:fundamentals/host/web-host) topic.
* Generic Host – Generic Host is new in ASP.NET Core 2.1. For more information, see the [Generic Host](xref:fundamentals/host/generic-host) topic.

::: moniker range=">= aspnetcore-3.0"

## Worker Service template

The ASP.NET Core Worker Service template provides a starting point for writing long running service apps. To use the template as a basis for a hosted services app:

# [Visual Studio](#tab/visual-studio)

1. Create a new project.
1. Select **ASP.NET Core Web Application**. Select **Next**.
1. Provide a project name in the **Project name** field or accept the default project name. Select **Create**.
1. In the **Create a new ASP.NET Core Web Application** dialog, confirm that **.NET Core** and **ASP.NET Core 3.0** are selected.
1. Select the **Worker Service** template. Select **Create**.

# [Visual Studio Code / .NET Core CLI](#tab/visual-studio-code+netcore-cli)

Use the Worker Service (`worker`) template with the [dotnet new](/dotnet/core/tools/dotnet-new) command from a command shell. In the following example, a Worker Service app is created named `ContosoWorkerService`. A folder for the `ContosoWorkerService` app is created automatically when the command is executed.

```console
dotnet new worker -o ContosoWorkerService
```

---

::: moniker-end

## Package

Reference the [Microsoft.AspNetCore.App metapackage](xref:fundamentals/metapackage-app) or add a package reference to the [Microsoft.Extensions.Hosting](https://www.nuget.org/packages/Microsoft.Extensions.Hosting) package.
Expand Down
31 changes: 30 additions & 1 deletion aspnetcore/host-and-deploy/windows-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Learn how to host an ASP.NET Core app in a Windows Service.
monikerRange: '>= aspnetcore-2.1'
ms.author: tdykstra
ms.custom: mvc
ms.date: 05/21/2019
ms.date: 06/03/2019
uid: host-and-deploy/windows-service
---
# Host ASP.NET Core in a Windows Service
Expand All @@ -21,6 +21,35 @@ An ASP.NET Core app can be hosted on Windows as a [Windows Service](/dotnet/fram
* [ASP.NET Core SDK 2.1 or later](https://dotnet.microsoft.com/download)
* [PowerShell 6.2 or later](https://github.com/PowerShell/PowerShell)

::: moniker range=">= aspnetcore-3.0"

## Worker Service template

The ASP.NET Core Worker Service template provides a starting point for writing long running service apps. To use the template as a basis for a Windows Service app:

1. Create a Worker Service app from the .NET Core template.
1. Follow the guidance in the [App configuration](#app-configuration) section to update the Worker Service app so that it can run as a Windows Service.

# [Visual Studio](#tab/visual-studio)

1. Create a new project.
1. Select **ASP.NET Core Web Application**. Select **Next**.
1. Provide a project name in the **Project name** field or accept the default project name. Select **Create**.
1. In the **Create a new ASP.NET Core Web Application** dialog, confirm that **.NET Core** and **ASP.NET Core 3.0** are selected.
1. Select the **Worker Service** template. Select **Create**.

# [Visual Studio Code / .NET Core CLI](#tab/visual-studio-code+netcore-cli)

Use the Worker Service (`worker`) template with the [dotnet new](/dotnet/core/tools/dotnet-new) command from a command shell. In the following example, a Worker Service app is created named `ContosoWorkerService`. A folder for the `ContosoWorkerService` app is created automatically when the command is executed.

```console
dotnet new worker -o ContosoWorkerService
```

---

::: moniker-end

## App configuration

::: moniker range=">= aspnetcore-3.0"
Expand Down

0 comments on commit 80eacc4

Please sign in to comment.