.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 parameter new to dotnet utility. 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 HelloWordl

 

As result, I received the following message:

dotnetnew

 

So far, the directory and files created are:

ls

 

If you take a look at the project file, in this case the HelloWorld.csproj, you will see what is the target framework and the application NuGet packages references.

nugetreferences

 

What is important to notice here is, that at this point we know at is the references but not where to get them and what is their dependencies. That is why it is necessary to run the following command to get the location of those references:

dotnet restore

 

The result expected is:

dotnetrestore

 

After restoring the references, the obj folder will be created with the following files.

obj

 

The project.assets.json is the file that contains details about the references and dependencies of our application.

 

assets

 

The .DLLs that are referenced in this file, can be found inside the NuGet package of the user profile.

nugetuserprofile

 

The next step is to build our application through 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: https://localhost:5000. Observe that we are not using IIS to host our application.

 

I hope you have enjoyed. Let me know if you have any questions.