How to create and run C# project

This post is just a reminder for me. So in order to find more details about dotnet CLI, follow the below link

https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet

1. Creating a C# project

-o or –output is location to place for new generated project.

dotnet new console -o enum_demo4
Folder Structure
Generated Project

2. Building – Compiling Project

Build the project in the current directory. It build project and its dependencies.

dotnet build

Build the specified project

dotnet build ./demo_app1

Build project and its dependencies using Release configuration

dotnet build --configuration Release

3. Running

Run the project in the current directory:

dotnet run

Run the specified project

dotnet run --project ./demo_app1/demo_app1.csproj

or

dotnet run -p./demo_app1/demo_app1.csproj

4. Cleaning

Clean the project in the current directory:

dotnet clean

Clean specified project:

dotnet clean ./demo_app1

Leave a Reply

Your email address will not be published. Required fields are marked *