1 Introduction

This article describes how to create ASP.NET Core web application using Yeoman template generator. When we create an ASP.NET Core application in windows platform, we can use visual studio templates. since ASP.NET Core is supported on Linux and Mac-like platforms, we can use template generator tool like Yeoman to create a basic project template.

↑ Return to Top

2 What is Yeoman?

Yeoman is a free open source tool. It’s more like Visual Studio project templates. It’s going to create a complete project with given set of tools. Yeoman has set of generators. It complies with industry best practices. Developers can easily start with their applications with a specific toolset, without worrying about the setup or template of the application. Yeoman templates include building, testing and minification in your application, So a developer can focus on the logic of their application.

↑ Return to Top

3 Install Node.js

install node

 sudo apt-get install nodejs
 node --version

Install Node.js, before installing Yeoman. Yeoman is going to run on a node server. After installing Node.js check the version of it.

↑ Return to Top

4 Install npm

install npm

 sudo apt install npm

When we install Node.js, npm also comes along with it. If you start installing npm before installing Node.js, follow like this.

npm is a package manager for Yeoman. It’s going to download any dependencies in your application. You don’t want to manually download and install it.

↑ Return to Top

5 Let’s try to install Yeoman!!

 npm install -g yo

Run Yo installer command.

Yeoman permission issue when installing

But it doesn’t seem work. We get an ugly permission issue. Let’s try to fix this.

It says permission denied for some paths. It suggests to run installer command as root/Administrator, Let’s try out that.

Install Yeoman as administrator

It looks perfectly fine when we use sudo command with yo installer command.

check whether Yeoman is installed properly


We can check whether Yeoman is installed properly using Yo command.

We have successfully installed Yeoman. Now we don’t want to manually create .NETCore applications. We can use generated templates using Yo. Let’s start using Yeoman templates.

Create a new directory and cd into it. Then run yo command.

Yo command

Run Yo command, and check what happens.

It points to Install a generator by default. It doesn’t point to run a generator until we install a generator.

install a generator

Search for ASP.NET generator in npm package management store.

install a generator

We get a permission issue when installing ASP.NET generator, Let’s try what yo says. It will run npm install command and see what happens.

install a generator using npm install command

 npm install -g generator

We tried to install generator using npm install command but it shows the same error!!!!

Since this is a permission issue, will run the command with sudo and check what happens.

install a generator as administrator

 sudo npm install -g generator-aspnet

When installing generator as an administrator, it installs without getting any errors.

Let’s run Yo command and select a template.

create empty web application using Yo

Select aspnet as a generator and then select what type of application you want to create.

Select Empty Web Application and give a name to it.

How it looks like after restoring packages

Go inside the project folder and open it in Visual Studio Code.

In Visual Studio Code add .vscode folder and restore relevant packages. It shows solution like this.

program.cs file

In program.cs file, It shows WebHostBuilder class, with cross-platform Kestrel server and IIS integration both.

It has defined a separate Startup class, to configure the HTTP request pipeline.

dotnet build and run application

Build and run .NETCore application and check terminal window.

You can see logging is enabled for browser navigation.

We can see the complete project is created using Yeoman template generator. It includes the program.cs, project.json, and web.config files.

It includes Startup class to manage the HTTP request pipeline. And also it has a wwwroot folder to host our web application.

Since Yeoman is generating the complete application, we don’t have to do anything manually. We can focus on the application logic and start working on it.

↑ Return to Top

6 Download

6.1 TechNet Gallery

↑ Return to Top

6.2 GitHub

↑ Return to Top

7 Conclusion

If you go through this article, you will understand how easy it is to create a basic .NET Core template using Yeoman.

↑ Return to Top

8 References

↑ Return to Top