.Net

dotnet new --list  #lists all dotnet templates
dotnet new webapp -o MyWebApp --no-https -f net6.0

What does this command mean?

The dotnet new command creates a new application.

  • The webApp parameter selects what template to use when creating your app.
  • The o parameter creates a directory named MyWebApp where your app is stored.
  • The -no-https flag specifies not to enable HTTPS.
  • The f parameter 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.cs contains the app startup code and middleware configuration.
  • The Pages directory contains some example web pages for the application.
  • MyWebApp.csproj defines some project settings, such as, .NET SDK version to target.
  • The launchSettings.json file inside the Properties directory 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.
SuperMade with Super