dotnet new --list #lists all dotnet templates
dotnet new webapp -o MyWebApp --no-https -f net6.0What does this command mean?
The dotnet new command creates a new application.
- The
webAppparameter selects what template to use when creating your app. - The
oparameter creates a directory namedMyWebAppwhere your app is stored. - The
-no-httpsflag specifies not to enable HTTPS. - The
fparameter indicates you're creating a .NET 6 application.
What files were created?
- App.csproj - A C# project file that tells it to target the .NET 6 runtime, and to reference a library from nuget (.NET's package manager).
- Program.cs - Provides the main entry point for .NET which uses an WebHostBuilder to initialize the server which listens for http requests.
- Startup.cs - Provides a class that is used to configure and control how http requests are handled by the server.
- appsettings.json - The configuration file for the .NET app, including sections for Kestrel and logging.
- Properties/launchSettings.json - A configuration file used by Visual Studio to tell it how to start the app when debugging.
Several files were created in the MyWebApp directory to give you a simple web application that is ready to run.
Program.cscontains the app startup code and middleware configuration.- The
Pagesdirectory contains some example web pages for the application. MyWebApp.csprojdefines some project settings, such as, .NET SDK version to target.- The
launchSettings.jsonfile inside thePropertiesdirectory defines different profile settings for the local development environment. A port number ranging between 5000-5300 is automatically assigned at project creation and saved on this file.