Visual Studio project types and templates

Visual Studio is the best IDE for Microsoft-related technology stacks. You can use Visual Studio whether you are planning to develop a desktop application for Windows or a web application for Windows Server. The best part of using Visual Studio is that the IDE will help you with lots of common tasks that you would have to perform manually if you were not using it. For example, if you were planning to create a web application using ASP.NET Model-View-Controller (MVC), Visual Studio can provide you a template for an MVC application. You can start with the template and modify it according to your requirements. Without this, you would have to download the packages, create the folders, and set the web configuration for the application. To get the full benefit of Visual Studio, you have to know the different projects and templates that come with it so that you can speed up your development process.

Let's take a look at the different project types that Visual Studio provides. After opening Visual Studio, if you click New Project, the following window will pop up:

Here, on the left-hand side, we can see the major categories of the projects: Recent, Installed, and Online. In the Recent tab, you can see the project types that have been used recently, so you don't have to search for commonly used project types every time. In the Installed tab, you will find the project types that are already installed on your computer. When you install Visual Studio, you can choose which workloads you want to install.

The Workloads window that will appear while installing Visual Studio looks as follows:

The Workloads options you choose have a direct relation to the installed project types. Under the Online tab, you will find the projects that were not installed when Visual Studio was installed. There are many project templates available for Visual Studio, which is why they are not all installed at once.

Now, if we expand the Installed tab, we will see that the different programming languages are shown as child tabs: Visual C#, Visual Basic, Visual C++, and so on. As this book relates to C#, we will only focus on the Visual C# area, as shown in the following screenshot:

If we expand the Visual C# tab, we will see more tabs that relate to more specific types of projects, such as Windows Desktop, Web, .NET Core, Test, and so on. But if we focus on the middle part of the window, we will see the different project templates, such as Windows Forms App (.NET Framework), Console App (.NET Core), Console App (.NET Framework), Class Library (.NET Standard), Class Library (.NET Framework), ASP .NET Core Web Application, ASP.NET Web Application (.NET Framework), and so on. On the right-hand side of the windows, we can see a short description of the project template that you have selected in the middle pane, as shown in the following screenshot:

Let's take a look at some of the most common project templates available in Visual Studio 2017:

  • Console App: A project to create a command-line application. There are two different types of this kind of project that are available: one for .NET Core and another for .NET Framework.
  • Class Library: You can use this template if you are developing a class library project that can be used as an extension code of another project. In Visual Studio 2017, you again get two options: .NET Standard and .NET Framework.
  • ASP.NET Core Web Application: This project is for web applications that use .NET Core, which is platform-independent. You can create MVC, web API, and SPA applications with this type of project.
  • ASP.NET Web Application (.NET Framework): This project template is used to develop web applications using .NET Framework. Similar to the ASP.NET Core Web Application template, with this project template, you can choose from MVC, web API, or SPA projects.
  • WCF Server Application: You can use this project type to create a Windows Communication Foundation (WCF) service.
  • WPF App (.NET Framework): You can choose this template if you are creating a Windows Presentation Foundation (WPF) project.
  • Unit Test Project (.NET Framework): This is a project for unit testing. If you create this project, you will get a premade test class, and you can use it to write your unit tests.

There are many other project templates available that are used by .NET developers. It is always better to start with a project template rather than a blank template if you are sure about your application's purpose.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.133.117