Create .NET Applications from the Terminal with Warp CLI

In the real world, when it comes to creating or deploying applications, once we leave our computers behind, we don’t use an IDE like Visual Studio or Rider. Instead, we perform all actions through the command line.

For example, in most companies, when you need to create a new project, you don't do it on your PC. Instead, you use an internal platform that creates the project, and when you create it, not only is the .NET project generated, but also the git repository, and—depending on how many additional elements your company uses—such as code analyzers, vulnerability scanners, etc., an environment is created for all of them.

 

But behind the scenes, we always use commands. Using the CLI in .NET isn't very popular, and I think one of the main reasons is that the default terminal in Windows just isn't good. Here comes the sponsor of this post, Warp, a powerful new terminal available for Windows which, in my honest opinion, is the first truly high-quality terminal in our wonderful ecosystem. 

 

Referral link for Warp: https://app.warp.dev/referral/9D4X54 

 

1 - Creating a .NET Project Using the Terminal 

 

The first step we're going to look at today is how to create a .NET project using the terminal.  

 

To create a .NET project, we need to use the dotnet new command and indicate the template type. Of course, there are more options, but you might not know them all, which means you can use dotnet new -h to view the help or run dotnet new list to see the available templates. 

 

dotnet new exmamples

 

In our case, we'll select a standard C# API project, so we run the following command

dotnet new webapi --output src --name TerminalExample

This will create the API inside a folder called src, which is standard in the .NET environment. With this, you could already run the API, but to open the project correctly with an IDE, we need a solution file, so let’s create one with the following command:

dotnet new sln

Now, we need to add the web api project we just created into this solution file.

In Warp, you can edit files directly by clicking in the terminal itself. But you can also use the .NET CLI to add the project to the solution with a command (Yes, this is also typically done in companies when creating projects). 

 

Chances are, if you’ve never done it, you might not remember the command. That’s not a problem; Warp has built-in AI (Ctrl+i), where you can choose between Claude, GPT, Gemini, or DeepSeek to ask for assistance. In this case, I'm going to ask it to create the command to add the project to the solution.

The AI gives us the correct answer and, not only that, you can also set up the AI agent to execute the commands automatically. 

If, for example, the command fails, the agent itself helps you debug the problem. 

In this case, I intentionally wrote the csproj filename incorrectly, and the agent itself scans the file system and finds one or more solutions that might work for you:

In our case, we run the following command

dotnet sln add src/TemplateExample.csproj//Output: Project `src\TerminalExample.csproj` added to the solution.

 

 

2 - Adding a Test Project in .NET Using the Terminal

 

A process very similar to the previous one: simply run the following command to add an xunit project, though you can use nunit or mstest:

dotnet new xunit -n TerminalExample.UnitTest -o Test

 

And we add the project to the solution: 

dotnet sln add Test/TerminalExample.UnitTest.csproj 

 

Now, I’ll just add a small use case and a test to see how it works:

public class ExampleUseCase{    public int Sum(int a, int b)    {        return a + b;    }}[Fact]public void TestSumIsCorrect(){    ExampleUseCase exampleUseCase = new ExampleUseCase();    int result = exampleUseCase.Sum(1, 2);    Assert.Equal(3, result);}

 

As we can see, after running build, Warp predicts what we're going to do, and simply by pressing shift and the right arrow key, we save ourselves from typing the command (this can be configured to use the tab key, for example). 

 

 

3 - Why It Is Important to Be Familiar with Terminal Commands

 

In C#, we don't usually use the Terminal, but in any other language or environment, the terminal or command line is an integral part of development. All of you who do frontend know this—absolutely everything in frontend is done through the command line; there isn’t an IDE like there is for C# that does everything for you. The same happens in languages like Ruby or DevOps environments, where absolutely everything is done via the terminal. 

 

Generally speaking, once you're familiar with it, performing actions in the terminal is much faster and simpler than using the interface. More importantly, it's more reliable, since command syntax rarely changes, whereas program interfaces are constantly being updated. 

 

If you’re a .NET developer and ever want to step outside this ecosystem, I highly recommend that you become comfortable using the terminal.

 

 

3.1 - Connecting to a Database via the Terminal

 

A very simple example: if you have an app deployed on some system and need to connect to the database because something's gone wrong, you don’t know exactly what, and you need to inspect the database. For security reasons, you can only access it from the machine itself, so you have to SSH into the machine and run SQL commands manually—simply to check the data.

 

We connect using the following command; in my case, this database is in Docker:

docker exec -it mysql-flagx0 mysql -u root -p

 

From here, we can query the database directly.

Here, we see that the client who called because their flag package isn’t working has their entry removed, so we manually re-enable it with the following query, also from the terminal: 

mysql> UPDATE flagdb.Flags t    -> SET t.DeletedtimeUtc = null,    ->     t.IsDeleted      = 0    -> WHERE t.Id = 1;Query OK, 1 row affected (0.01 sec)Rows matched: 1  Changed: 1  Warnings: 0

 

 

4 - Other Important .NET Commands in the Terminal

 

Within .NET, there are many commands to run, but some are more important and of course more common.

 

We've seen how to create both projects and solutions, but in addition, here are some others: 

 

dotnet build to build a project, where you can pass --configuration Release to build in release mode. 

 

dotnet run to run a project, where you need to provide --project projectpath.csproj if you have more than one. 

 

There are several NuGet commands, although I usually use the GUI for most things except dotnet nuget locals all --clear to clear the nuget cache, which in newer versions isn’t as necessary, but if you work with .NET Framework, I'm sure you've needed to run it several times. 

 

dotnet test to run tests within the solution; you can add filters or save test results using the --logger parameter. 

 

In .NET, we have tools that we can run from the command line, such as the entire helper package for Entity Framework, though there are many more. 

 

Finally, deployment commands, where you can use dontnet publish -c Release -o ./destinationFolder to publish an app in release mode—this is the code you will deploy.



If you liked the post and plan to use Warp, don’t forget you can use my referral code! https://app.warp.dev/referral/9D4X54 

Best regards!

This post was translated from Spanish. You can see the original one here.
If there is any problem you can add a comment bellow or contact me in the website's contact form

© copyright 2025 NetMentor | Todos los derechos reservados | RSS Feed

Buy me a coffee Invitame a un café