Browse Source

Remove IIS launch profiles from templates (#56489)

* Remove IIS launch profiles from templates

VS now supports showing the IIS Express launch option all the time and will auto-create the launch profile if one doesn't already exist.
Fixes #46501
Fixes #42818

* Update tests

* Update MvcTemplateTest.cs

* Fix templates

* Fix trailing comma
Damian Edwards 1 year ago
parent
commit
143d72dcb2
16 changed files with 67 additions and 257 deletions
  1. 3 3
      src/ProjectTemplates/Shared/BlazorTemplateTest.cs
  2. 0 14
      src/ProjectTemplates/Shared/Project.cs
  3. 5 23
      src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWeb-CSharp/Properties/launchSettings.json
  4. 5 26
      src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Properties/launchSettings.json
  5. 5 25
      src/ProjectTemplates/Web.ProjectTemplates/content/EmptyWeb-CSharp/Properties/launchSettings.json
  6. 5 20
      src/ProjectTemplates/Web.ProjectTemplates/content/EmptyWeb-FSharp/Properties/launchSettings.json
  7. 5 25
      src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Properties/launchSettings.json
  8. 5 25
      src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Properties/launchSettings.json
  9. 5 25
      src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/Properties/launchSettings.json
  10. 5 26
      src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Properties/launchSettings.json
  11. 5 26
      src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Properties/launchSettings.json
  12. 2 2
      src/ProjectTemplates/test/Templates.Mvc.Tests/BlazorTemplateTest.cs
  13. 5 5
      src/ProjectTemplates/test/Templates.Mvc.Tests/MvcTemplateTest.cs
  14. 5 5
      src/ProjectTemplates/test/Templates.Mvc.Tests/RazorPagesTemplateTest.cs
  15. 5 5
      src/ProjectTemplates/test/Templates.Mvc.Tests/WebApiTemplateTest.cs
  16. 2 2
      src/ProjectTemplates/test/Templates.Tests/EmptyWebTemplateTest.cs

+ 3 - 3
src/ProjectTemplates/Shared/BlazorTemplateTest.cs

@@ -62,10 +62,10 @@ public abstract class BlazorTemplateTest : LoggedTest
                                 || (!serverProject && auth is not null);
             var noHttps = args?.Contains(ArgConstants.NoHttps) ?? false;
             var expectedLaunchProfileNames = requiresHttps
-                ? new[] { "https", "IIS Express" }
+                ? new[] { "https" }
                 : noHttps
-                    ? new[] { "http", "IIS Express" }
-                    : new[] { "http", "https", "IIS Express" };
+                    ? new[] { "http" }
+                    : new[] { "http", "https" };
             await project.VerifyLaunchSettings(expectedLaunchProfileNames);
         }
 

+ 0 - 14
src/ProjectTemplates/Shared/Project.cs

@@ -329,20 +329,6 @@ public class Project : IDisposable
 
             // Check there are no more launch profiles defined
             Assert.False(profilesEnumerator.MoveNext());
-
-            if (launchSettings.RootElement.TryGetProperty("iisSettings", out var iisSettings)
-                && iisSettings.TryGetProperty("iisExpress", out var iisExpressSettings))
-            {
-                var iisSslPort = iisExpressSettings.GetProperty("sslPort").GetInt32();
-                if (expectedLaunchProfileNames.Contains("https"))
-                {
-                    Assert.True(iisSslPort >= 44300 && iisSslPort <= 44399, $"IIS Express port was expected to be >= 44300 and <= 44399 but was {iisSslPort} in file {filePath}");
-                }
-                else
-                {
-                    Assert.Equal(0, iisSslPort);
-                }
-            }
         }
     }
 

+ 5 - 23
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWeb-CSharp/Properties/launchSettings.json

@@ -1,17 +1,5 @@
 {
   "$schema": "https://json.schemastore.org/launchsettings.json",
-    "iisSettings": {
-      "windowsAuthentication": false,
-      "anonymousAuthentication": true,
-      "iisExpress": {
-        "applicationUrl": "http://localhost:8080",
-        //#if (HasHttpsProfile)
-        "sslPort": 44300
-        //#else
-        "sslPort": 0
-        //#endif
-      }
-    },
     "profiles": {
       //#if (HasHttpProfile)
       "http": {
@@ -25,7 +13,11 @@
         "environmentVariables": {
           "ASPNETCORE_ENVIRONMENT": "Development"
         }
+      //#if (HasHttpsProfile)
       },
+      //#else
+      }
+      //#endif
       //#endif
       //#if (HasHttpsProfile)
       "https": {
@@ -39,17 +31,7 @@
         "environmentVariables": {
           "ASPNETCORE_ENVIRONMENT": "Development"
         }
-      },
-      //#endif
-      "IIS Express": {
-        "commandName": "IISExpress",
-        "launchBrowser": true,
-        //#if (UseWebAssembly)
-        "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
-        //#endif
-        "environmentVariables": {
-          "ASPNETCORE_ENVIRONMENT": "Development"
-        }
       }
+      //#endif
     }
   }

+ 5 - 26
src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Properties/launchSettings.json

@@ -1,22 +1,5 @@
 {
   "$schema": "https://json.schemastore.org/launchsettings.json",
-  "iisSettings": {
-    //#if (WindowsAuth)
-    "windowsAuthentication": true,
-    "anonymousAuthentication": false,
-    //#else
-    "windowsAuthentication": false,
-    "anonymousAuthentication": true,
-    //#endif
-    "iisExpress": {
-      "applicationUrl": "http://localhost:8080",
-      //#if (HasHttpsProfile)
-      "sslPort": 44300
-      //#else
-      "sslPort": 0
-      //#endif
-    }
-  },
   "profiles": {
     //#if (HasHttpProfile)
     "http": {
@@ -28,7 +11,11 @@
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
+    //#if (HasHttpsProfile)
     },
+    //#else
+    }
+    //#endif
     //#endif
     //#if (HasHttpsProfile)
     "https": {
@@ -40,15 +27,7 @@
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
-    },
-    //#endif
-    "IIS Express": {
-      "commandName": "IISExpress",
-      "launchBrowser": true,
-      "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
-      "environmentVariables": {
-        "ASPNETCORE_ENVIRONMENT": "Development"
-      }
     }
+    //#endif
   }
 }

+ 5 - 25
src/ProjectTemplates/Web.ProjectTemplates/content/EmptyWeb-CSharp/Properties/launchSettings.json

@@ -1,22 +1,5 @@
 {
   "$schema": "https://json.schemastore.org/launchsettings.json",
-  "iisSettings": {
-    //#if (WindowsAuth)
-    "windowsAuthentication": true,
-    "anonymousAuthentication": false,
-    //#else
-    "windowsAuthentication": false,
-    "anonymousAuthentication": true,
-    //#endif
-    "iisExpress": {
-      "applicationUrl": "http://localhost:8080",
-      //#if (HasHttpsProfile)
-      "sslPort": 44300
-      //#else
-      "sslPort": 0
-      //#endif
-    }
-  },
   "profiles": {
     "http": {
       "commandName": "Project",
@@ -26,7 +9,11 @@
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
+    //#if (HasHttpsProfile)
     },
+    //#else
+    }
+    //#endif
     //#if (HasHttpsProfile)
     "https": {
       "commandName": "Project",
@@ -36,14 +23,7 @@
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
-    },
-    //#endif
-    "IIS Express": {
-      "commandName": "IISExpress",
-      "launchBrowser": true,
-      "environmentVariables": {
-        "ASPNETCORE_ENVIRONMENT": "Development"
-      }
     }
+    //#endif
   }
 }

+ 5 - 20
src/ProjectTemplates/Web.ProjectTemplates/content/EmptyWeb-FSharp/Properties/launchSettings.json

@@ -1,17 +1,5 @@
 {
   "$schema": "https://json.schemastore.org/launchsettings.json",
-  "iisSettings": {
-    "windowsAuthentication": false,
-    "anonymousAuthentication": true,
-    "iisExpress": {
-      "applicationUrl": "http://localhost:8080",
-      //#if (HasHttpsProfile)
-      "sslPort": 44300
-      //#else
-      "sslPort": 0
-      //#endif
-    }
-  },
   "profiles": {
     "http": {
       "commandName": "Project",
@@ -21,7 +9,11 @@
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
+    //#if (HasHttpsProfile)
     },
+    //#else
+    }
+    //#endif
     //#if (HasHttpsProfile)
     "https": {
       "commandName": "Project",
@@ -31,14 +23,7 @@
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
-    },
-    //#endif
-    "IIS Express": {
-      "commandName": "IISExpress",
-      "launchBrowser": true,
-      "environmentVariables": {
-        "ASPNETCORE_ENVIRONMENT": "Development"
-      }
     }
+    //#endif
   }
 }

+ 5 - 25
src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Properties/launchSettings.json

@@ -1,22 +1,5 @@
 {
   "$schema": "https://json.schemastore.org/launchsettings.json",
-  "iisSettings": {
-    //#if (WindowsAuth)
-    "windowsAuthentication": true,
-    "anonymousAuthentication": false,
-    //#else
-    "windowsAuthentication": false,
-    "anonymousAuthentication": true,
-    //#endif
-    "iisExpress": {
-      "applicationUrl": "http://localhost:8080",
-      //#if (HasHttpsProfile)
-      "sslPort": 44300
-      //#else
-      "sslPort": 0
-      //#endif
-    }
-  },
   "profiles": {
     //#if (HasHttpProfile)
     "http": {
@@ -27,7 +10,11 @@
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
+    //#if (HasHttpsProfile)
     },
+    //#else
+    }
+    //#endif
     //#endif
     //#if (HasHttpsProfile)
     "https": {
@@ -38,14 +25,7 @@
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
-    },
-    //#endif
-    "IIS Express": {
-      "commandName": "IISExpress",
-      "launchBrowser": true,
-      "environmentVariables": {
-        "ASPNETCORE_ENVIRONMENT": "Development"
-      }
     }
+    //#endif
   }
 }

+ 5 - 25
src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Properties/launchSettings.json

@@ -1,22 +1,5 @@
 {
   "$schema": "https://json.schemastore.org/launchsettings.json",
-  "iisSettings": {
-    //#if (WindowsAuth)
-    "windowsAuthentication": true,
-    "anonymousAuthentication": false,
-    //#else
-    "windowsAuthentication": false,
-    "anonymousAuthentication": true,
-    //#endif
-    "iisExpress": {
-      "applicationUrl": "http://localhost:8080",
-      //#if (HasHttpsProfile)
-      "sslPort": 44300
-      //#else
-      "sslPort": 0
-      //#endif
-    }
-  },
   "profiles": {
     //#if (HasHttpProfile)
     "http": {
@@ -27,7 +10,11 @@
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
+    //#if (HasHttpsProfile)
     },
+    //#else
+    }
+    //#endif
     //#endif
     //#if (HasHttpsProfile)
     "https": {
@@ -38,14 +25,7 @@
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
-    },
-    //#endif
-    "IIS Express": {
-      "commandName": "IISExpress",
-      "launchBrowser": true,
-      "environmentVariables": {
-        "ASPNETCORE_ENVIRONMENT": "Development"
-      }
     }
+    //#endif
   }
 }

+ 5 - 25
src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/Properties/launchSettings.json

@@ -1,22 +1,5 @@
 {
   "$schema": "https://json.schemastore.org/launchsettings.json",
-  "iisSettings": {
-    //#if (WindowsAuth)
-    "windowsAuthentication": true,
-    "anonymousAuthentication": false,
-    //#else
-    "windowsAuthentication": false,
-    "anonymousAuthentication": true,
-    //#endif
-    "iisExpress": {
-      "applicationUrl": "http://localhost:8080",
-      //#if (HasHttpsProfile)
-      "sslPort": 44300
-      //#else
-      "sslPort": 0
-      //#endif
-    }
-  },
   "profiles": {
     "http": {
       "commandName": "Project",
@@ -26,7 +9,11 @@
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
+    //#if (HasHttpsProfile)
     },
+    //#else
+    }
+    //#endif
     //#if (HasHttpsProfile)
     "https": {
       "commandName": "Project",
@@ -36,14 +23,7 @@
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
-    },
-    //#endif
-    "IIS Express": {
-      "commandName": "IISExpress",
-      "launchBrowser": true,
-      "environmentVariables": {
-        "ASPNETCORE_ENVIRONMENT": "Development"
-      }
     }
+    //#endif
   }
 }

+ 5 - 26
src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Properties/launchSettings.json

@@ -1,22 +1,5 @@
 {
   "$schema": "https://json.schemastore.org/launchsettings.json",
-  "iisSettings": {
-    //#if (WindowsAuth)
-    "windowsAuthentication": true,
-    "anonymousAuthentication": false,
-    //#else
-    "windowsAuthentication": false,
-    "anonymousAuthentication": true,
-    //#endif
-    "iisExpress": {
-      "applicationUrl": "http://localhost:8080",
-      //#if (HasHttpsProfile)
-      "sslPort": 44300
-      //#else
-      "sslPort": 0
-      //#endif
-    }
-  },
   "profiles": {
     //#if (HasHttpProfile)
     "http": {
@@ -28,7 +11,11 @@
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
+    //#if (HasHttpsProfile)
     },
+    //#else
+    }
+    //#endif
     //#endif
     //#if (HasHttpsProfile)
     "https": {
@@ -40,15 +27,7 @@
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
-    },
-    //#endif
-    "IIS Express": {
-      "commandName": "IISExpress",
-      "launchBrowser": true,
-      "launchUrl": "weatherforecast",
-      "environmentVariables": {
-        "ASPNETCORE_ENVIRONMENT": "Development"
-      }
     }
+    //#endif
   }
 }

+ 5 - 26
src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Properties/launchSettings.json

@@ -1,22 +1,5 @@
 {
   "$schema": "https://json.schemastore.org/launchsettings.json",
-  "iisSettings": {
-    //#if (WindowsAuth)
-    "windowsAuthentication": true,
-    "anonymousAuthentication": false,
-    //#else
-    "windowsAuthentication": false,
-    "anonymousAuthentication": true,
-    //#endif
-    "iisExpress": {
-      "applicationUrl": "http://localhost:8080",
-      //#if (HasHttpsProfile)
-      "sslPort": 44300
-      //#else
-      "sslPort": 0
-      //#endif
-    }
-  },
   "profiles": {
     "http": {
       "commandName": "Project",
@@ -27,7 +10,11 @@
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
+    //#if (HasHttpsProfile)
     },
+    //#else
+    }
+    //#endif
     //#if (HasHttpsProfile)
     "https": {
       "commandName": "Project",
@@ -38,15 +25,7 @@
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
-    },
-    //#endif
-    "IIS Express": {
-      "commandName": "IISExpress",
-      "launchBrowser": true,
-      "launchUrl": "weatherforecast",
-      "environmentVariables": {
-        "ASPNETCORE_ENVIRONMENT": "Development"
-      }
     }
+    //#endif
   }
 }

+ 2 - 2
src/ProjectTemplates/test/Templates.Mvc.Tests/BlazorTemplateTest.cs

@@ -57,8 +57,8 @@ public class BlazorTemplateTest : LoggedTest
         await project.RunDotNetNewAsync("blazor", args: args);
 
         var expectedLaunchProfileNames = args.Contains(ArgConstants.NoHttps)
-            ? new[] { "http", "IIS Express" }
-            : new[] { "http", "https", "IIS Express" };
+            ? new[] { "http" }
+            : new[] { "http", "https" };
         await project.VerifyLaunchSettings(expectedLaunchProfileNames);
 
         var projectFileContents = await ReadProjectFileAsync(project);

+ 5 - 5
src/ProjectTemplates/test/Templates.Mvc.Tests/MvcTemplateTest.cs

@@ -59,8 +59,8 @@ public class MvcTemplateTest : LoggedTest
 
         var noHttps = args?.Contains(ArgConstants.NoHttps) ?? false;
         var expectedLaunchProfileNames = noHttps
-            ? new[] { "http", "IIS Express" }
-            : new[] { "http", "https", "IIS Express" };
+            ? new[] { "http" }
+            : new[] { "http", "https" };
         await project.VerifyLaunchSettings(expectedLaunchProfileNames);
 
         var projectExtension = languageOverride == "F#" ? "fsproj" : "csproj";
@@ -157,8 +157,8 @@ public class MvcTemplateTest : LoggedTest
         await project.RunDotNetNewAsync("mvc", auth: "Individual", useLocalDB: useLocalDB, args: args);
 
         var expectedLaunchProfileNames = noHttps
-            ? new[] { "http", "IIS Express" }
-            : new[] { "http", "https", "IIS Express" };
+            ? new[] { "http" }
+            : new[] { "http", "https" };
         await project.VerifyLaunchSettings(expectedLaunchProfileNames);
 
         var projectFileContents = project.ReadFile($"{project.ProjectName}.csproj");
@@ -355,7 +355,7 @@ public class MvcTemplateTest : LoggedTest
         await project.RunDotNetNewAsync("mvc", auth: auth, args: args);
 
         // Identity Web auth requires https and thus ignores the --no-https option if passed so there should never be an 'http' profile
-        var expectedLaunchProfileNames = new[] { "https", "IIS Express" };
+        var expectedLaunchProfileNames = new[] { "https" };
         await project.VerifyLaunchSettings(expectedLaunchProfileNames);
 
         // Verify building in debug works

+ 5 - 5
src/ProjectTemplates/test/Templates.Mvc.Tests/RazorPagesTemplateTest.cs

@@ -54,8 +54,8 @@ public class RazorPagesTemplateTest : LoggedTest
         await project.RunDotNetNewAsync("razor", args: args);
 
         var expectedLaunchProfileNames = noHttps
-            ? new[] { "http", "IIS Express" }
-            : new[] { "http", "https", "IIS Express" };
+            ? new[] { "http" }
+            : new[] { "http", "https" };
         await project.VerifyLaunchSettings(expectedLaunchProfileNames);
 
         var projectFileContents = ReadFile(project.TemplateOutputDir, $"{project.ProjectName}.csproj");
@@ -148,8 +148,8 @@ public class RazorPagesTemplateTest : LoggedTest
 
         // Individual auth supports no https OK
         var expectedLaunchProfileNames = noHttps
-            ? new[] { "http", "IIS Express" }
-            : new[] { "http", "https", "IIS Express" };
+            ? new[] { "http" }
+            : new[] { "http", "https" };
         await project.VerifyLaunchSettings(expectedLaunchProfileNames);
 
         var projectFileContents = ReadFile(project.TemplateOutputDir, $"{project.ProjectName}.csproj");
@@ -293,7 +293,7 @@ public class RazorPagesTemplateTest : LoggedTest
         await project.RunDotNetNewAsync("razor", auth: auth, args: args);
 
         // Identity Web auth requires https and thus ignores the --no-https option if passed so there should never be an 'http' profile
-        var expectedLaunchProfileNames = new[] { "https", "IIS Express" };
+        var expectedLaunchProfileNames = new[] { "https" };
         await project.VerifyLaunchSettings(expectedLaunchProfileNames);
 
         // Verify building in debug works

+ 5 - 5
src/ProjectTemplates/test/Templates.Mvc.Tests/WebApiTemplateTest.cs

@@ -195,8 +195,8 @@ public class WebApiTemplateTest : LoggedTest
 
         var noHttps = args.Contains(ArgConstants.NoHttps);
         var expectedLaunchProfileNames = noHttps
-            ? new[] { "http", "IIS Express" }
-            : new[] { "http", "https", "IIS Express" };
+            ? new[] { "http" }
+            : new[] { "http", "https" };
         await project.VerifyLaunchSettings(expectedLaunchProfileNames);
 
         await project.RunDotNetBuildAsync();
@@ -220,10 +220,10 @@ public class WebApiTemplateTest : LoggedTest
                             || string.Equals(auth, "SingleOrg", StringComparison.OrdinalIgnoreCase);
         var noHttps = args?.Contains(ArgConstants.NoHttps) ?? false;
         var expectedLaunchProfileNames = requiresHttps
-            ? new[] { "https", "IIS Express" }
+            ? new[] { "https" }
             : noHttps
-                ? new[] { "http", "IIS Express" }
-                : new[] { "http", "https", "IIS Express" };
+                ? new[] { "http" }
+                : new[] { "http", "https" };
         await project.VerifyLaunchSettings(expectedLaunchProfileNames);
 
         // Avoid the F# compiler. See https://github.com/dotnet/aspnetcore/issues/14022

+ 2 - 2
src/ProjectTemplates/test/Templates.Tests/EmptyWebTemplateTest.cs

@@ -79,8 +79,8 @@ public class EmptyWebTemplateTest : LoggedTest
 
         var noHttps = args?.Contains(ArgConstants.NoHttps) ?? false;
         var expectedLaunchProfileNames = noHttps
-            ? new[] { "http", "IIS Express" }
-            : new[] { "http", "https", "IIS Express" };
+            ? new[] { "http" }
+            : new[] { "http", "https" };
         await project.VerifyLaunchSettings(expectedLaunchProfileNames);
 
         // Avoid the F# compiler. See https://github.com/dotnet/aspnetcore/issues/14022