Skip to content

Commit 25b4171

Browse files
authored
Update templates to incorporate net7 changes (#42802)
* Leverage auto-registration of AuthNZ middlewares * Update Swashbuckle.AspNetCore version * Set accelerator key for UseProgramMain * Update remaining template config * Update src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/.template.config/localize/templatestrings.en.json
1 parent 94c00f2 commit 25b4171

File tree

29 files changed

+33
-86
lines changed

29 files changed

+33
-86
lines changed

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@
284284
<SerilogSinksFileVersion>4.0.0</SerilogSinksFileVersion>
285285
<StackExchangeRedisVersion>2.2.4</StackExchangeRedisVersion>
286286
<SystemReactiveLinqVersion>5.0.0</SystemReactiveLinqVersion>
287-
<SwashbuckleAspNetCoreVersion>6.2.3</SwashbuckleAspNetCoreVersion>
287+
<SwashbuckleAspNetCoreVersion>6.4.0</SwashbuckleAspNetCoreVersion>
288288
<XunitAbstractionsVersion>2.0.3</XunitAbstractionsVersion>
289289
<XunitAnalyzersVersion>0.10.0</XunitAnalyzersVersion>
290290
<XunitVersion>2.4.1</XunitVersion>

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/.template.config/localize/templatestrings.en.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@
3434
"symbols/CallsMicrosoftGraph/description": "Specifies if the web app calls Microsoft Graph. This option only applies if --auth SingleOrg or --auth MultiOrg is specified.",
3535
"symbols/CalledApiScopes/description": "Scopes to request to call the API from the web app. This option only applies if --auth SingleOrg, --auth MultiOrg or --auth IndividualB2C is specified.",
3636
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
37-
"symbols/UseProgramMain/displayName": "Do not use top-level statements",
37+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
38+
"_symbols/UseProgramMain/displayName.comment": "Use '_' as accelerator key when translating.",
3839
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
3940
"postActions/restore/description": "Restore NuGet packages required by this project.",
4041
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
41-
}
42+
}

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/.template.config/template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@
518518
"type": "parameter",
519519
"datatype": "bool",
520520
"defaultValue": "false",
521-
"displayName": "Do not use top-level statements",
521+
"displayName": "Do not use _top-level statements",
522522
"description": "Whether to generate an explicit Program class and Main method instead of top-level statements."
523523
}
524524
},

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Program.Main.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,6 @@ public static void Main(string[] args)
153153

154154
app.UseRouting();
155155

156-
#if (OrganizationalAuth || IndividualAuth || WindowsAuth)
157-
app.UseAuthentication();
158-
app.UseAuthorization();
159-
160-
#endif
161156
#if (OrganizationalAuth || IndividualAuth)
162157
app.MapControllers();
163158
#endif

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Program.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,6 @@
147147

148148
app.UseRouting();
149149

150-
#if (OrganizationalAuth || IndividualAuth || WindowsAuth)
151-
app.UseAuthentication();
152-
app.UseAuthorization();
153-
154-
#endif
155150
#if (OrganizationalAuth || IndividualAuth)
156151
app.MapControllers();
157152
#endif

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/.template.config/localize/templatestrings.en.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@
3636
"symbols/CalledApiUrl/description": "URL of the API to call from the web app. This option only applies if --auth SingleOrg, --auth MultiOrg or --auth IndividualB2C without and ASP.NET Core host is specified.",
3737
"symbols/CallsMicrosoftGraph/description": "Specifies if the web app calls Microsoft Graph. This option only applies if --auth SingleOrg or --auth MultiOrg is specified.",
3838
"symbols/CalledApiScopes/description": "Scopes to request to call the API from the web app. This option only applies if --auth SingleOrg, --auth MultiOrg or --auth IndividualB2C without and ASP.NET Core host is specified.",
39-
"symbols/UseProgramMain/displayName": "Do not use top-level statements",
39+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
40+
"_symbols/UseProgramMain/displayName.comment": "Use '_' as accelerator key when translating.",
4041
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
4142
"postActions/restore/description": "Restore NuGet packages required by this project.",
4243
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'",
4344
"postActions/restoreClient/description": "Restore NuGet packages required by this project.",
4445
"postActions/restoreClient/manualInstructions/default/text": "Run 'dotnet restore'",
4546
"postActions/open-file/description": "Opens Readme.txt in the editor"
46-
}
47+
}

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/.template.config/template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@
631631
"type": "parameter",
632632
"datatype": "bool",
633633
"defaultValue": "false",
634-
"displayName": "Do not use top-level statements",
634+
"displayName": "Do not use _top-level statements",
635635
"description": "Whether to generate an explicit Program class and Main method instead of top-level statements."
636636
}
637637
},

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Program.Main.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,6 @@ public static void Main(string[] args)
107107

108108
#if (IndividualLocalAuth)
109109
app.UseIdentityServer();
110-
#endif
111-
#if (OrganizationalAuth || IndividualAuth)
112-
app.UseAuthentication();
113-
#endif
114-
#if (!NoAuth)
115-
app.UseAuthorization();
116-
117110
#endif
118111

119112
app.MapRazorPages();

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Program.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,6 @@
101101

102102
#if (IndividualLocalAuth)
103103
app.UseIdentityServer();
104-
#endif
105-
#if (OrganizationalAuth || IndividualAuth)
106-
app.UseAuthentication();
107-
#endif
108-
#if (!NoAuth)
109-
app.UseAuthorization();
110-
111104
#endif
112105

113106
app.MapRazorPages();

src/ProjectTemplates/Web.ProjectTemplates/content/EmptyWeb-CSharp/.template.config/localize/templatestrings.en.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
"symbols/Framework/choices/net7.0/description": "Target net7.0",
1212
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
1313
"symbols/NoHttps/description": "Whether to turn off HTTPS. This option only applies if Individual, IndividualB2C, SingleOrg, or MultiOrg aren't used for --auth.",
14-
"symbols/UseProgramMain/displayName": "Do not use top-level statements",
14+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
15+
"_symbols/UseProgramMain/displayName.comment": "Use '_' as accelerator key when translating.",
1516
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
1617
"postActions/restore/description": "Restore NuGet packages required by this project.",
1718
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
18-
}
19+
}

src/ProjectTemplates/Web.ProjectTemplates/content/EmptyWeb-CSharp/.template.config/template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
"type": "parameter",
181181
"datatype": "bool",
182182
"defaultValue": "false",
183-
"displayName": "Do not use top-level statements",
183+
"displayName": "Do not use _top-level statements",
184184
"description": "Whether to generate an explicit Program class and Main method instead of top-level statements."
185185
}
186186
},

src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.en.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
99
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
1010
"symbols/kestrelHttpsPort/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).",
11-
"symbols/UseProgramMain/displayName": "Do not use top-level statements",
11+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
12+
"_symbols/UseProgramMain/displayName.comment": "Use '_' as accelerator key when translating.",
1213
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
1314
"postActions/restore/description": "Restore NuGet packages required by this project.",
1415
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
15-
}
16+
}

src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
"type": "parameter",
123123
"datatype": "bool",
124124
"defaultValue": "false",
125-
"displayName": "Do not use top-level statements",
125+
"displayName": "Do not use _top-level statements",
126126
"description": "Whether to generate an explicit Program class and Main method instead of top-level statements."
127127
}
128128
},

src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/.template.config/localize/templatestrings.en.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@
3434
"symbols/CalledApiUrl/description": "URL of the API to call from the web app. This option only applies if --auth SingleOrg, --auth MultiOrg or --auth IndividualB2C is specified.",
3535
"symbols/CallsMicrosoftGraph/description": "Specifies if the web app calls Microsoft Graph. This option only applies if --auth SingleOrg or --auth MultiOrg is specified.",
3636
"symbols/CalledApiScopes/description": "Scopes to request to call the API from the web app. This option only applies if --auth SingleOrg, --auth MultiOrg or --auth IndividualB2C is specified.",
37-
"symbols/UseProgramMain/displayName": "Do not use top-level statements",
37+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
38+
"_symbols/UseProgramMain/displayName.comment": "Use '_' as accelerator key when translating.",
3839
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
3940
"postActions/restore/description": "Restore NuGet packages required by this project.",
4041
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
41-
}
42+
}

src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/.template.config/template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@
434434
"type": "parameter",
435435
"datatype": "bool",
436436
"defaultValue": "false",
437-
"displayName": "Do not use top-level statements",
437+
"displayName": "Do not use _top-level statements",
438438
"description": "Whether to generate an explicit Program class and Main method instead of top-level statements."
439439
}
440440
},

src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Program.Main.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,6 @@ public static void Main(string[] args)
140140

141141
app.UseRouting();
142142

143-
#if (OrganizationalAuth || IndividualAuth || WindowsAuth)
144-
app.UseAuthentication();
145-
#endif
146-
app.UseAuthorization();
147-
148143
app.MapRazorPages();
149144
#if (IndividualB2CAuth || OrganizationalAuth)
150145
app.MapControllers();

src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Program.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,6 @@
134134

135135
app.UseRouting();
136136

137-
#if (OrganizationalAuth || IndividualAuth || WindowsAuth)
138-
app.UseAuthentication();
139-
#endif
140-
app.UseAuthorization();
141-
142137
app.MapRazorPages();
143138
#if (IndividualB2CAuth || OrganizationalAuth)
144139
app.MapControllers();

src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/.template.config/localize/templatestrings.en.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@
3434
"symbols/CalledApiUrl/description": "URL of the API to call from the web app. This option only applies if --auth SingleOrg, --auth MultiOrg or --auth IndividualB2C is specified.",
3535
"symbols/CallsMicrosoftGraph/description": "Specifies if the web app calls Microsoft Graph. This option only applies if --auth SingleOrg or --auth MultiOrg is specified.",
3636
"symbols/CalledApiScopes/description": "Scopes to request to call the API from the web app. This option only applies if --auth SingleOrg, --auth MultiOrg or --auth IndividualB2C is specified.",
37-
"symbols/UseProgramMain/displayName": "Do not use top-level statements",
37+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
38+
"_symbols/UseProgramMain/displayName.comment": "Use '_' as accelerator key when translating.",
3839
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
3940
"postActions/restore/description": "Restore NuGet packages required by this project.",
4041
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
41-
}
42+
}

src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/.template.config/template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@
430430
"type": "parameter",
431431
"datatype": "bool",
432432
"defaultValue": "false",
433-
"displayName": "Do not use top-level statements",
433+
"displayName": "Do not use _top-level statements",
434434
"description": "Whether to generate an explicit Program class and Main method instead of top-level statements."
435435
}
436436
},

src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Program.Main.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,6 @@ public static void Main(string[] args)
142142

143143
app.UseRouting();
144144

145-
#if (OrganizationalAuth || IndividualAuth || WindowsAuth)
146-
app.UseAuthentication();
147-
#endif
148-
app.UseAuthorization();
149-
150145
app.MapControllerRoute(
151146
name: "default",
152147
pattern: "{controller=Home}/{action=Index}/{id?}");

src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Program.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,6 @@
136136

137137
app.UseRouting();
138138

139-
#if (OrganizationalAuth || IndividualAuth || WindowsAuth)
140-
app.UseAuthentication();
141-
#endif
142-
app.UseAuthorization();
143-
144139
app.MapControllerRoute(
145140
name: "default",
146141
pattern: "{controller=Home}/{action=Index}/{id?}");

src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/.template.config/localize/templatestrings.en.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131
"symbols/CallsMicrosoftGraph/description": "Specifies if the web app calls Microsoft Graph. This option only applies if --auth SingleOrg is specified.",
3232
"symbols/CalledApiScopes/description": "Scopes to request to call the API from the web app. This option only applies if --auth SingleOrg or --auth IndividualB2C is specified.",
3333
"symbols/DisableOpenAPI/description": "Disable OpenAPI (Swagger) support",
34-
"symbols/UseProgramMain/displayName": "Do not use top-level statements",
34+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
35+
"_symbols/UseProgramMain/displayName.comment": "Use '_' as accelerator key when translating.",
3536
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
3637
"postActions/restore/description": "Restore NuGet packages required by this project.",
3738
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
38-
}
39+
}

src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/.template.config/template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@
398398
"type": "parameter",
399399
"datatype": "bool",
400400
"defaultValue": "false",
401-
"displayName": "Do not use top-level statements",
401+
"displayName": "Do not use _top-level statements",
402402
"description": "Whether to generate an explicit Program class and Main method instead of top-level statements."
403403
}
404404
},

src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.Main.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ public static void Main(string[] args)
8989
app.UseHttpsRedirection();
9090
#endif
9191

92-
#if (OrganizationalAuth || IndividualAuth || WindowsAuth)
93-
app.UseAuthentication();
94-
#endif
95-
app.UseAuthorization();
96-
9792
#if (UseMinimalAPIs)
9893
#if (OrganizationalAuth || IndividualB2CAuth)
9994
var scopeRequiredByApi = app.Configuration["AzureAd:Scopes"] ?? "";

src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.MinimalAPIs.OrgOrIndividualB2CAuth.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@
6161
app.UseHttpsRedirection();
6262
#endif
6363

64-
app.UseAuthentication();
65-
app.UseAuthorization();
66-
6764
var scopeRequiredByApi = app.Configuration["AzureAd:Scopes"] ?? "";
6865
var summaries = new[]
6966
{

src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.MinimalAPIs.WindowsOrNoAuth.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@
3535

3636
app.UseHttpsRedirection();
3737
#endif
38-
#if (WindowsAuth)
39-
app.UseAuthentication();
40-
app.UseAuthorization();
41-
#endif
4238

4339
var summaries = new[]
4440
{

src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@
7777
app.UseHttpsRedirection();
7878
#endif
7979

80-
#if (OrganizationalAuth || IndividualAuth || WindowsAuth)
81-
app.UseAuthentication();
82-
#endif
83-
app.UseAuthorization();
84-
8580
app.MapControllers();
8681

8782
app.Run();

src/ProjectTemplates/Web.ProjectTemplates/content/Worker-CSharp/.template.config/localize/templatestrings.en.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
"symbols/Framework/description": "The target framework for the project.",
77
"symbols/Framework/choices/net7.0/description": "Target net7.0",
88
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
9-
"symbols/UseProgramMain/displayName": "Do not use top-level statements",
9+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
10+
"_symbols/UseProgramMain/displayName.comment": "Use '_' as accelerator key when translating.",
1011
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
1112
"postActions/restore/description": "Restore NuGet packages required by this project.",
1213
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
13-
}
14+
}

src/ProjectTemplates/Web.ProjectTemplates/content/Worker-CSharp/.template.config/template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"type": "parameter",
8888
"datatype": "bool",
8989
"defaultValue": "false",
90-
"displayName": "Do not use top-level statements",
90+
"displayName": "Do not use _top-level statements",
9191
"description": "Whether to generate an explicit Program class and Main method instead of top-level statements."
9292
}
9393
},

0 commit comments

Comments
 (0)