From a722c4cd7a3a1ed7ea8f10727d1cf802753b0e2d Mon Sep 17 00:00:00 2001 From: Phillip Carter Date: Wed, 1 Jul 2020 15:51:45 -0700 Subject: [PATCH] Add F# worker service template (#22042) --- .../Worker-FSharp.fsproj.in | 19 ++++ .../.template.config/cs-CZ/strings.json | 7 ++ .../.template.config/de-DE/strings.json | 7 ++ .../.template.config/dotnetcli.host.json | 19 ++++ .../.template.config/en/strings.json | 7 ++ .../.template.config/es-ES/strings.json | 7 ++ .../.template.config/fr-FR/strings.json | 7 ++ .../.template.config/it-IT/strings.json | 7 ++ .../.template.config/ja-JP/strings.json | 7 ++ .../.template.config/ko-KR/strings.json | 7 ++ .../.template.config/pl-PL/strings.json | 7 ++ .../.template.config/pt-BR/strings.json | 7 ++ .../.template.config/ru-RU/strings.json | 7 ++ .../.template.config/template.json | 91 ++++++++++++++++++ .../.template.config/tr-TR/strings.json | 7 ++ .../.template.config/vs-2017.3.host.json | 20 ++++ .../.template.config/vs-2017.3/Worker.png | Bin 0 -> 230 bytes .../.template.config/zh-CN/strings.json | 7 ++ .../.template.config/zh-TW/strings.json | 7 ++ .../content/Worker-FSharp/Program.fs | 20 ++++ .../Properties/launchSettings.json | 10 ++ .../content/Worker-FSharp/Worker.fs | 21 ++++ .../appsettings.Development.json | 9 ++ .../content/Worker-FSharp/appsettings.json | 9 ++ 24 files changed, 316 insertions(+) create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/Worker-FSharp.fsproj.in create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/cs-CZ/strings.json create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/de-DE/strings.json create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/dotnetcli.host.json create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/en/strings.json create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/es-ES/strings.json create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/fr-FR/strings.json create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/it-IT/strings.json create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/ja-JP/strings.json create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/ko-KR/strings.json create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/pl-PL/strings.json create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/pt-BR/strings.json create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/ru-RU/strings.json create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/template.json create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/tr-TR/strings.json create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/vs-2017.3.host.json create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/vs-2017.3/Worker.png create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/zh-CN/strings.json create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/zh-TW/strings.json create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/Program.fs create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/Properties/launchSettings.json create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/Worker.fs create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/appsettings.Development.json create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/appsettings.json diff --git a/src/ProjectTemplates/Web.ProjectTemplates/Worker-FSharp.fsproj.in b/src/ProjectTemplates/Web.ProjectTemplates/Worker-FSharp.fsproj.in new file mode 100644 index 0000000000..da9f1118cf --- /dev/null +++ b/src/ProjectTemplates/Web.ProjectTemplates/Worker-FSharp.fsproj.in @@ -0,0 +1,19 @@ + + + + ${DefaultNetCoreTargetFramework} + dotnet-Company.Application1-53bc9b9d-9d6a-45d4-8429-2a2761773502 + True + Company.Application1 + + + + + + + + + + + + diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/cs-CZ/strings.json b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/cs-CZ/strings.json new file mode 100644 index 0000000000..848fb37c87 --- /dev/null +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/cs-CZ/strings.json @@ -0,0 +1,7 @@ +{ + "version": "1.0.0.0", + "strings": { + "name": "Služba pracovního procesu", + "description": "Šablona prázdného projektu pro vytvoření služby pracovního procesu" + } +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/de-DE/strings.json b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/de-DE/strings.json new file mode 100644 index 0000000000..ecec877156 --- /dev/null +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/de-DE/strings.json @@ -0,0 +1,7 @@ +{ + "version": "1.0.0.0", + "strings": { + "name": "Workerdienst", + "description": "Eine leere Projektvorlage zum Erstellen eines Workerdiensts." + } +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/dotnetcli.host.json b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/dotnetcli.host.json new file mode 100644 index 0000000000..b1cf98e39b --- /dev/null +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/dotnetcli.host.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json.schemastore.org/dotnetcli.host", + "symbolInfo": { + "Framework": { + "longName": "framework" + }, + "skipRestore": { + "longName": "no-restore", + "shortName": "" + }, + "ExcludeLaunchSettings": { + "longName": "exclude-launch-settings", + "shortName": "" + } + }, + "usageExamples": [ + "" + ] +} diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/en/strings.json b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/en/strings.json new file mode 100644 index 0000000000..0b13cebb97 --- /dev/null +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/en/strings.json @@ -0,0 +1,7 @@ +{ + "version": "1.0.0.0", + "strings": { + "name": "Worker Service", + "description": "An empty project template for creating a worker service." + } +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/es-ES/strings.json b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/es-ES/strings.json new file mode 100644 index 0000000000..4e3cf14930 --- /dev/null +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/es-ES/strings.json @@ -0,0 +1,7 @@ +{ + "version": "1.0.0.0", + "strings": { + "name": "Servicio de trabajo", + "description": "Una plantilla de proyecto vacío para crear un servicio de trabajo." + } +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/fr-FR/strings.json b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/fr-FR/strings.json new file mode 100644 index 0000000000..fd4416d5fe --- /dev/null +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/fr-FR/strings.json @@ -0,0 +1,7 @@ +{ + "version": "1.0.0.0", + "strings": { + "name": "Service Worker", + "description": "Modèle de projet vide pour la création d'un service Worker." + } +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/it-IT/strings.json b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/it-IT/strings.json new file mode 100644 index 0000000000..7bdfc52e86 --- /dev/null +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/it-IT/strings.json @@ -0,0 +1,7 @@ +{ + "version": "1.0.0.0", + "strings": { + "name": "Servizio di ruolo di lavoro", + "description": "Modello di progetto vuoto per la creazione di servizio del ruolo di lavoro." + } +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/ja-JP/strings.json b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/ja-JP/strings.json new file mode 100644 index 0000000000..2de2e6b432 --- /dev/null +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/ja-JP/strings.json @@ -0,0 +1,7 @@ +{ + "version": "1.0.0.0", + "strings": { + "name": "ワーカー サービス", + "description": "ワーカー サービスを作成するための空のプロジェクト テンプレート。" + } +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/ko-KR/strings.json b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/ko-KR/strings.json new file mode 100644 index 0000000000..4c48bf1283 --- /dev/null +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/ko-KR/strings.json @@ -0,0 +1,7 @@ +{ + "version": "1.0.0.0", + "strings": { + "name": "작업자 서비스", + "description": "작업자 서비스를 만들기 위한 빈 프로젝트의 템플릿입니다." + } +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/pl-PL/strings.json b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/pl-PL/strings.json new file mode 100644 index 0000000000..e4b11c845e --- /dev/null +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/pl-PL/strings.json @@ -0,0 +1,7 @@ +{ + "version": "1.0.0.0", + "strings": { + "name": "Usługa procesu roboczego", + "description": "Szablon pustego projektu służący do tworzenia usługi procesu roboczego." + } +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/pt-BR/strings.json b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/pt-BR/strings.json new file mode 100644 index 0000000000..d61f922597 --- /dev/null +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/pt-BR/strings.json @@ -0,0 +1,7 @@ +{ + "version": "1.0.0.0", + "strings": { + "name": "Serviço de Trabalho", + "description": "Um modelo de projeto vazio para criar um serviço de trabalho." + } +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/ru-RU/strings.json b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/ru-RU/strings.json new file mode 100644 index 0000000000..457c379060 --- /dev/null +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/ru-RU/strings.json @@ -0,0 +1,7 @@ +{ + "version": "1.0.0.0", + "strings": { + "name": "Служба рабочих ролей", + "description": "Шаблон пустого проекта для создания службы рабочих ролей." + } +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/template.json b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/template.json new file mode 100644 index 0000000000..d3b56d1431 --- /dev/null +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/template.json @@ -0,0 +1,91 @@ +{ + "$schema": "http://json.schemastore.org/template", + "author": "Microsoft", + "classifications": [ + "Common", + "Worker", + "Web" + ], + "name": "Worker Service", + "generatorVersions": "[1.0.0.0-*)", + "description": "An empty project template for creating a worker service.", + "groupIdentity": "Microsoft.Worker.Empty", + "precedence": "7000", + "identity": "Microsoft.Worker.Empty.FSharp.5.0", + "shortName": "worker", + "tags": { + "language": "F#", + "type": "project" + }, + "sourceName": "Company.Application1", + "preferNameDirectory": true, + "guids": [ + "53bc9b9d-9d6a-45d4-8429-2a2761773502" + ], + "sources": [ + { + "modifiers": [ + { + "condition": "(ExcludeLaunchSettings)", + "exclude": [ + "Properties/launchSettings.json" + ] + } + ] + } + ], + "symbols": { + "ExcludeLaunchSettings": { + "type": "parameter", + "datatype": "bool", + "defaultValue": "false", + "description": "Whether to exclude launchSettings.json from the generated template." + }, + "Framework": { + "type": "parameter", + "description": "The target framework for the project.", + "datatype": "choice", + "choices": [ + { + "choice": "net5.0", + "description": "Target net5.0" + } + ], + "replaces": "net5.0", + "defaultValue": "net5.0" + }, + "copyrightYear": { + "type": "generated", + "generator": "now", + "replaces": "copyrightYear", + "parameters": { + "format": "yyyy" + } + }, + "skipRestore": { + "type": "parameter", + "datatype": "bool", + "description": "If specified, skips the automatic restore of the project on create.", + "defaultValue": "false" + } + }, + "primaryOutputs": [ + { + "path": "Company.Application1.fsproj" + } + ], + "defaultName": "WorkerService", + "postActions": [ + { + "condition": "(!skipRestore)", + "description": "Restore NuGet packages required by this project.", + "manualInstructions": [ + { + "text": "Run 'dotnet restore'" + } + ], + "actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025", + "continueOnError": true + } + ] +} diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/tr-TR/strings.json b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/tr-TR/strings.json new file mode 100644 index 0000000000..9a2afe2425 --- /dev/null +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/tr-TR/strings.json @@ -0,0 +1,7 @@ +{ + "version": "1.0.0.0", + "strings": { + "name": "Çalışan Hizmeti", + "description": "Çalışan hizmeti oluşturmaya yönelik bir boş proje şablonu." + } +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/vs-2017.3.host.json b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/vs-2017.3.host.json new file mode 100644 index 0000000000..c64e1a0951 --- /dev/null +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/vs-2017.3.host.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json.schemastore.org/vs-2017.3.host", + "name": { + "text": "Worker Service", + "package": "{0CD94836-1526-4E85-87D3-FB5274C5AFC9}", + "id": "1025" + }, + "description": { + "text": "An empty project template for creating a worker service.", + "package": "{0CD94836-1526-4E85-87D3-FB5274C5AFC9}", + "id": "1026" + }, + "order": 300, + "icon": "vs-2017.3/Worker.png", + "learnMoreLink": "https://go.microsoft.com/fwlink/?linkid=2072778", + "uiFilters": [ "oneaspnet" ], + "supportsDocker": true, + "excludeLaunchSettings": false, + "minFullFrameworkVersion": "4.6.1" +} diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/vs-2017.3/Worker.png b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/.template.config/vs-2017.3/Worker.png new file mode 100644 index 0000000000000000000000000000000000000000..c9249297de47d63db327119d577687a09e2c30e1 GIT binary patch literal 230 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?4jBOuH;Rhv&5C^*B@ z#WAEJ?(OuAyayC`SQHn1G~k&yuXRR4>x;=N7pVBEn0xrEuuM$79zSRPakkr0#@4S5 zW_vS=98h#zyS20Iz_g$?D;`B3))SWhb(rrY&JX#g>!Imrc + services.AddHostedService() |> ignore) + + [] + let main args = + createHostBuilder(args).Build().Run() + + 0 // exit code \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/Properties/launchSettings.json b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/Properties/launchSettings.json new file mode 100644 index 0000000000..2c42dbde5c --- /dev/null +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "Company.Application1": { + "commandName": "Project", + "environmentVariables": { + "DOTNET_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/Worker.fs b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/Worker.fs new file mode 100644 index 0000000000..56d6c27ff7 --- /dev/null +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/Worker.fs @@ -0,0 +1,21 @@ +namespace Company.Application1 + +open System +open System.Collections.Generic +open System.Linq +open System.Threading +open System.Threading.Tasks +open Microsoft.Extensions.Hosting +open Microsoft.Extensions.Logging + +type Worker(logger: ILogger) = + inherit BackgroundService() + + override _.ExecuteAsync(ct: CancellationToken) = + async { + while not ct.IsCancellationRequested do + logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now) + do! Async.Sleep(1000) + } + |> Async.StartAsTask + :> Task // need to convert into the parameter-less task \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/appsettings.Development.json b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/appsettings.Development.json new file mode 100644 index 0000000000..8983e0fc1c --- /dev/null +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/appsettings.json b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/appsettings.json new file mode 100644 index 0000000000..8983e0fc1c --- /dev/null +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/Worker-FSharp/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +}