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 builddnrun: Alias fordotnet run. Runs a .NET project. Command:dotnet rundntest: Alias fordotnet test. Runs unit tests for a .NET project. Command:dotnet testdnclean: Alias fordotnet clean. Cleans build outputs of a .NET project. Command:dotnet cleandnpublish: Alias fordotnet publish. Publishes a .NET project for deployment. Command:dotnet publishdnscaffold: 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 restorednadd: 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 packdnstore: Stores .NET packages in runtime store. Command:dotnet storednwatch: Starts a .NET project and restarts it when files change. Command:dotnet watch rundnexec: Executes a .NET application. Command:dotnet exec {application}dnformat: Formats .NET code. Command:dotnet formatdnformatcheck: Checks if .NET code is formatted. Command:dotnet format --checkdnformatfix: 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 webapidnwebapp: Creates a new ASP.NET Core Web App project. Command:dotnet new webappdnweb: Creates a new ASP.NET Core Empty project. Command:dotnet new webdnconsole: Creates a new Console Application project. Command:dotnet new consolednclasslib: Creates a new Class Library project. Command:dotnet new classlibdnmvc: Creates a new ASP.NET Core MVC project. Command:dotnet new mvcdnrazor: Creates a new Razor Pages project. Command:dotnet new razordnwebconfig: 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 Individualdnwebappauth: Creates a new ASP.NET Core Web App project with Individual authentication. Command:dotnet new webapp --auth Individualdnwebauth: Creates a new ASP.NET Core Empty project with Individual authentication. Command:dotnet new web --auth Individualdnconsoleauth: 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 testdnwatchdebug: Starts a .NET project with debugging and restarts it when files change. Command:dotnet watch --project {project} rundnwatchtestdebug: 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 slndnaddprj: 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