How to create API Project with .NET Core CLI

  1. Open the command line and go to the directory that you want to install.
  2. Execute Following command
    dotnet -hNOTE: You can see the list of  template that you can create with following command.
    ‘dotnet new -l’
  3. Create Solution file with following command:
    dotnet new sln’  — this will create the solution with the same name as the folder.
  4. Create a new api project with specifying output folder with option ‘-o’.
    dotnet new webapi -o <folder name>’ 
  5. Add project that you created with step 4 to solution file.
    dotnet sln add <folder name>’ 
  6. Open the Visual Studio and run debug.
    You will see the Swagger as below.
    Note: this will be added automatically from .NET Core 5.0 framework.
    With earlier version than 5.0, you need to set it up manually.

  7. Happy coding by changing your controller.  🙂

Leave a Reply