.NET Core 1.1 – Creating an ASP.NET Core using the .NET CLI


If you are new with .NET Core 1.1, please take a look at the post .NET Core 1.1 – Where to Start first.

After having the SDK installed, the first step is to open up the command prompt (I am using PowerShell as I am using Windows) and type the following command to visualize all of the options available for us:

dotnet -h

As result, will be displayed the parameters that dotnet CLI offers to us:

dotneth

 

As the parameter name suggest, to create a new project, we need to pass the new parameter to dotnet. But before running that command, you can use the -h parameter to get more options like templates and examples, as follows:

dotnet new -h

As expected, the templates and examples available are displayed as expected:

dotnetnewh

 

For demonstration propose, I am going to create a new ASP.NET Core MVC application, using the following command:

dotnet new mvc -n HelloWord

As result, I received the following message:

dotnetnew

So far, the directory and files created are:

ls

 

Observe that the bin folder does not exists so far and we don’t have any binary so far, even the binaries of the references. So, the next step, is to get the binaries of the references (NUGET packages) by running the following command:

dotnet restore

The result expected is:

dotnetrestore

 

Alright, now with the dependencies already set to our project, the next step is to build our application running the following command:

dotnet build

The result expected is:

dotnetbuild

 

To run the application, use the following command:

dotnet run

As result, we expect the following message:

dotnetrun

Now, you can access your application using the following address: http://localhost:5000. Observe that we are not using IIS to host our application.

 

Comments (0)

Skip to main content