From d39ed09c29dbd05b13f4129eb50d0940e9f2bea5 Mon Sep 17 00:00:00 2001
From: Artak <34246760+mkArtakMSFT@users.noreply.github.com>
Date: Sun, 9 Feb 2020 12:21:47 -0800
Subject: [PATCH] Auto-generate random port and proper project settings for the
 server project (#18842)

---
 .../.template.config/template.json            | 40 +++++++++++++++++++
 .../Server/Properties/launchSettings.json     |  2 +-
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/.template.config/template.json b/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/.template.config/template.json
index b6cb64fcec5..1c18d08504a 100644
--- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/.template.config/template.json
+++ b/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/.template.config/template.json
@@ -107,6 +107,46 @@
       "datatype": "bool",
       "defaultValue": "false",
       "description": "If specified, includes an ASP.NET Core host for the Blazor app."
+    },
+    "HttpPort": {
+      "type": "parameter",
+      "datatype": "integer",
+      "description": "Port number to use for the HTTP endpoint in launchSettings.json."
+    },
+    "HttpPortGenerated": {
+      "type": "generated",
+      "generator": "port"
+    },
+    "HttpPortReplacer": {
+      "type": "generated",
+      "generator": "coalesce",
+      "parameters": {
+        "sourceVariableName": "HttpPort",
+        "fallbackVariableName": "HttpPortGenerated"
+      },
+      "replaces": "8080"
+    },
+    "HttpsPort": {
+      "type": "parameter",
+      "datatype": "integer",
+      "description": "Port number to use for the HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used)."
+    },
+    "HttpsPortGenerated": {
+      "type": "generated",
+      "generator": "port",
+      "parameters": {
+        "low": 44300,
+        "high": 44399
+      }
+    },
+    "HttpsPortReplacer": {
+      "type": "generated",
+      "generator": "coalesce",
+      "parameters": {
+        "sourceVariableName": "HttpsPort",
+        "fallbackVariableName": "HttpsPortGenerated"
+      },
+      "replaces": "44300"
     }
   },
   "tags": {
diff --git a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Properties/launchSettings.json b/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Properties/launchSettings.json
index 3cf9f85e48c..83b55ad0289 100644
--- a/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Properties/launchSettings.json
+++ b/src/ProjectTemplates/BlazorWasm.ProjectTemplates/content/BlazorWasm-CSharp/Server/Properties/launchSettings.json
@@ -20,7 +20,7 @@
           "ASPNETCORE_ENVIRONMENT": "Development"
         }
       },
-      "Company.WebApplication1": {
+      "BlazorWasm-CSharp.Server": {
         "commandName": "Project",
         "launchBrowser": true,
         //#if(RequiresHttps)
-- 
GitLab