Closed AYColumbia closed 12 months ago
What SDK version are you using? The options still show up in help output in .NET 8 RC2.
What SDK version are you using? The options still show up in help output in .NET 8 RC2.
I'll have to check my work computer tomorrow and post the version info. I use chocolatey to keep things up to date so I may be on a different one by now. I'm on .net 7 and definitely NOT on .net 8.
Here's the dotnet info output.
.NET SDK:
Version: 7.0.403
Commit: 142776d834
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.403\
Host:
Version: 7.0.13
Architecture: x64
Commit: 3f73a2f186
.NET SDKs installed:
3.1.426 [C:\Program Files\dotnet\sdk]
5.0.403 [C:\Program Files\dotnet\sdk]
5.0.408 [C:\Program Files\dotnet\sdk]
5.0.416 [C:\Program Files\dotnet\sdk]
6.0.124 [C:\Program Files\dotnet\sdk]
6.0.319 [C:\Program Files\dotnet\sdk]
7.0.403 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.24 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.21 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.24 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
I also re-ran the dotnet command dotnet new webapi -h
and here's the output (without the swtiches listed):
ASP.NET Core Web API (C#)
Author: Microsoft
Description: A project template for creating an ASP.NET Core application with an example Controller for a RESTful HTTP service. This template can also be used for ASP.NET Core MVC Views and Controllers.
Usage:
dotnet new webapi [options] [template options]
Options:
-n, --name <name> The name for the output being created. If no name is specified, the name of the output
directory is used.
-o, --output <output> Location to place the generated output.
--dry-run Displays a summary of what would happen if the given command line were run if it would result
in a template creation.
--force Forces content to be generated even if it would change existing files.
--no-update-check Disables checking for the template package updates when instantiating a template.
--project <project> The project that should be used for context evaluation.
-lang, --language <C#> Specifies the template language to instantiate.
--type <project> Specifies the template type to instantiate.
Template options:
-au, --auth <None|IndividualB2C|...> The type of authentication to use
Type: choice
None No authentication
IndividualB2C Individual authentication with Azure AD B2C
SingleOrg Organizational authentication for a single tenant
Windows Windows authentication
Default: None
--aad-b2c-instance <aad-b2c-instance> The Azure Active Directory B2C instance to connect to (use with
IndividualB2C auth).
Type: string
Default: https://qualified.domain.name.b2clogin.com/
-ssp, --susi-policy-id <susi-policy-id> The sign-in and sign-up policy ID for this project (use with IndividualB2C
auth).
Type: string
Default: b2c_1_susi
--aad-instance <aad-instance> The Azure Active Directory instance to connect to (use with SingleOrg auth).
Type: string
Default: https://login.microsoftonline.com/
--client-id <client-id> The Client ID for this project (use with SingleOrg or IndividualB2C auth).
Type: string
Default: 11111111-1111-1111-11111111111111111
--domain <domain> The domain for the directory tenant (use with SingleOrg or IndividualB2C
auth).
Type: string
Default: qualified.domain.name
--default-scope <default-scope> The API scope the client needs to request to provision an access token. (use
with IndividualB2C, SingleOrg).
Type: string
Default: access_as_user
--tenant-id <tenant-id> The TenantId ID of the directory to connect to (use with SingleOrg auth).
Type: string
Default: 22222222-2222-2222-2222-222222222222
-r, --org-read-access Whether or not to allow this application read access to the directory (only
applies to SingleOrg auth).
Type: bool
Default: false
--exclude-launch-settings Whether to exclude launchSettings.json in the generated template.
Type: bool
Default: false
--no-https Whether to turn off HTTPS. This option only applies if IndividualB2C,
SingleOrg, or MultiOrg aren't used for --auth.
Type: bool
Default: false
-uld, --use-local-db Whether to use LocalDB instead of SQLite. This option only applies if --auth
Individual or --auth IndividualB2C is specified.
Type: bool
Default: false
-minimal, --use-minimal-apis Whether to use minimal APIs instead of controllers.
Type: bool
Default: false
-f, --framework <net7.0|net6.0|...> The target framework for the project.
Type: choice
net7.0 Target net7.0
net6.0 Target net6.0
net5.0 Target net5.0
netcoreapp3.1 Target netcoreapp3.1
netcoreapp2.1 Target netcoreapp2.1
Default: net7.0
--no-restore If specified, skips the automatic restore of the project on create.
Type: bool
Default: false
--called-api-url <called-api-url> URL of the API to call from the web app. This option only applies if --auth
SingleOrg or --auth IndividualB2C is specified.
Type: string
Default: https://graph.microsoft.com/v1.0
--calls-graph Specifies if the web app calls Microsoft Graph. This option only applies if
--auth SingleOrg is specified.
Type: bool
Default: false
--called-api-scopes <called-api-scopes> Scopes to request to call the API from the web app. This option only applies
if --auth SingleOrg or --auth IndividualB2C is specified.
Type: string
Default: user.read
--no-openapi Disable OpenAPI (Swagger) support
Type: bool
Default: false
--use-program-main Whether to generate an explicit Program class and Main method instead of
top-level statements.
Type: bool
Default: false
To see help for other template languages (F#), use --language option:
dotnet new webapi -h --language F#
Thanks for that information. This option was added in .NET 8, so I'm adding a note to the article stating that it's available since .NET 8.
Type of issue
Outdated article
Description
The current "dotnet new webapi" does NOT support either of the --controllers, --use-controllers switches.
Page URL
https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-new-sdk-templates
Content source URL
https://github.com/dotnet/docs/blob/main/docs/core/tools/dotnet-new-sdk-templates.md
Document Version Independent Id
af236ebe-5a79-fb2b-42a0-e5720ee732ae
Article author
tdykstra
Associated WorkItem - 180757