dotNet Commands
Here is a list of common dotnet commands used for managing .NET projects and solutions:
General Commands
dotnet --versionDisplays the version of the .NET SDK installed.
dotnet --infoDisplays information about the installed .NET SDKs and runtimes.
dotnet new --listLists all available templates for creating new projects.
Creating a New Project
dotnet new <template>
Creates a new project or file using the specified template. Examples:
dotnet new console- Creates a new console application.dotnet new mvc- Creates a new ASP.NET Core MVC web application.dotnet new classlib- Creates a new class library.
dotnet new <template> -n <name>
Specifies a name for the new project. Example:dotnet new console -n MyApp
Building and Running
dotnet buildBuilds the project.
dotnet runRuns the application (for executable projects).
dotnet publishPublishes the application for deployment.
Adding and Managing Dependencies
dotnet add package <package-name>
Adds a NuGet package to the project. Example:
dotnet list packageLists the NuGet packages installed in the project.
dotnet remove package <package-name>Removes a NuGet package from the project.
Project Management
dotnet sln <solution.sln> add <project.csproj>Adds a project to a solution file.
dotnet sln <solution.sln> remove <project.csproj>Removes a project from a solution file.
dotnet cleanCleans the build output.
Testing
dotnet test
Runs tests in the project.
Tool Management
dotnet tool install -g <tool-name>Installs a global tool.
dotnet tool list --globalLists all globally installed tools.
dotnet tool uninstall -g <tool-name>Uninstalls a global tool.
Miscellaneous
dotnet watch runWatches for file changes and automatically rebuilds and reruns the application.
dotnet formatFormats the code in the project according to style rules.
If you need specific examples or details about any command, let me know!