Published
- 3 min read
Boost Your .NET Development with Handy Aliases and Functions
🚀 Boost Your .NET Development with Handy Aliases and Functions
Working with .NET Core CLI can be a bit verbose at times. To speed up your development workflow, you can use command line aliases and functions. Here are some that I use frequently:
Aliases
dnbuild
: Alias fordotnet build
. Builds a .NET project. Command:dotnet build
dnrun
: Alias fordotnet run
. Runs a .NET project. Command:dotnet run
dntest
: Alias fordotnet test
. Runs unit tests for a .NET project. Command:dotnet test
dnclean
: Alias fordotnet clean
. Cleans build outputs of a .NET project. Command:dotnet clean
dnpublish
: Alias fordotnet publish
. Publishes a .NET project for deployment. Command:dotnet publish
dnscaffold
: Alias fordotnet aspnet-codegenerator
. Scaffolds items in an ASP.NET Core project. Command:dotnet aspnet-codegenerator
Functions
dnnew
: Creates a new .NET project. Command:dotnet new {template}
dnrestore
: Restores the dependencies and tools of a .NET project. Command:dotnet restore
dnadd
: Adds a package or reference to a .NET project. Command:dotnet add {project} {package/reference}
dnremove
: Removes a package or reference from a .NET project. Command:dotnet remove {project} {package/reference}
dnlist
: Lists all projects and installed packages for a .NET project. Command:dotnet list {project}
dnpack
: Creates a NuGet package of your .NET code. Command:dotnet pack
dnstore
: Stores .NET packages in runtime store. Command:dotnet store
dnwatch
: Starts a .NET project and restarts it when files change. Command:dotnet watch run
dnexec
: Executes a .NET application. Command:dotnet exec {application}
dnformat
: Formats .NET code. Command:dotnet format
dnformatcheck
: Checks if .NET code is formatted. Command:dotnet format --check
dnformatfix
: Formats .NET code and fixes any issues. Command:dotnet format --fix
Functions for scaffolding various .NET project types
dnwebapi
: Creates a new ASP.NET Core Web API project. Command:dotnet new webapi
dnwebapp
: Creates a new ASP.NET Core Web App project. Command:dotnet new webapp
dnweb
: Creates a new ASP.NET Core Empty project. Command:dotnet new web
dnconsole
: Creates a new Console Application project. Command:dotnet new console
dnclasslib
: Creates a new Class Library project. Command:dotnet new classlib
dnmvc
: Creates a new ASP.NET Core MVC project. Command:dotnet new mvc
dnrazor
: Creates a new Razor Pages project. Command:dotnet new razor
dnwebconfig
: Creates a new Web Config file. Command:dotnet new webconfig
Functions for scaffolding various .NET project types with authentication
dnwebapiauth
: Creates a new ASP.NET Core Web API project with Individual authentication. Command:dotnet new webapi --auth Individual
dnwebappauth
: Creates a new ASP.NET Core Web App project with Individual authentication. Command:dotnet new webapp --auth Individual
dnwebauth
: Creates a new ASP.NET Core Empty project with Individual authentication. Command:dotnet new web --auth Individual
dnconsoleauth
: Creates a new Console Application project with Individual authentication. Command:dotnet new console --auth Individual
Functions for testing and debugging
dnwatchtest
: Starts a .NET project and runs tests when files change. Command:dotnet watch test
dnwatchdebug
: Starts a .NET project with debugging and restarts it when files change. Command:dotnet watch --project {project} run
dnwatchtestdebug
: Starts a .NET project, runs tests with debugging and restarts it when files change. Command:dotnet watch --project {project} test
Functions for setting up solution and studio files
dnsln
: Creates a new Solution file. Command:dotnet new sln
dnaddprj
: Adds a project to a Solution file. Command:dotnet sln add {project}
dnremprj
: Removes a project from a Solution file. Command:dotnet sln remove {project}
dnlistprj
: Lists all projects in a Solution file. Command:dotnet sln list