vendredi 22 juillet 2016

How we can start using Visual Studio 2015 with .NET Core Tooling


Visual studio is used to improve developer productivity inside the editor, the goal now is to reduce actions and automate it to reduce time lost and focus on the code quality, best practices and limit bugs.
So Microsoft, worked all these years to give the better tool to developer from Visual Studio 2005 until Visual Studio 2015 we can touch the difference between them.
.NET Core RC2 is finally here, and this time it is a “Release Candidate” rather than an RC1 Beta. Now, we talk about .NET Core and its  cross-platform capabilities. This focus on Linux and Mac OS X support has led not only to a new .NET API but also an accompanying implementation and even a set of tools. In this article I will explain  the various .NET Core project types, the details of the new file types and their functions.

Let's start !

Before leveraging .NET Core RC2, we have to do some updates to our tools :
1- Download the .NET Core Tooling Preview 1 for Visual Studio 2015 :Visual Studio 2015 Update 3 and  .NET Core 1.0 for Visual Studio.
2- Install the NuGet Package Manager from bit.ly/27Rmeaj.
3- Create a new project : 
As you can see, there are three project types (Visual C#\Web and Visual C#\.NET Core folders). Each project type generates a different file's type :
Let's take a look to the structure of every project in this figure : 
As we can see, we can't find App.config or <appname>.config that was used from .NET Framework 1.0 as configuration file but we still have Web.config for ASP.NET Core Web Application (.NET Core). 
Properties\AssemblyInfo.cs : exist in Class Library and Console Application, it identifies the assembly data such as configuration, company, product and trademark. It was released in 2000.
Class1.cs
is a skeleton C# class file for the Class1 class and includes its default constructor, we found it in Class Library instead of Program.cs.
Global.json : is generated automatically for  every .NET Core project; it's used to for project’s node to identifies additional locations for source code when debugging.
Properties\launchSettings.json :  identifies the various Web hosting configuration settings: for example, by .NET Core Configuration we can identify the environment (development, test or production); SSL and authentication. Changes made from the Debug tab on Project Properties Window of Visual Studio provide a UI for editing the launchSettings.json file, as shown in this figure : 
Project.json is a new project file used in all .NET Core projects, It identifies lot of things like project references, build options (the version number), and identifies the platform to compile to—whether .NET Core or .NET Framework, it's build to replace the NuGet File Manager package.config file because it identifies the NuGet references for the project. it specify the frameworks supported in the project and the configuration required, it identify the target platform for self-contained apps. Note that the project is a portable app, project.json identifies which frameworks the project expects to be installed on the target machine on which the assembly will execute.
Project.lock.json : store the list of file like Nuget References that the project need them to compile. It includes also specific package version numbers, unlike the project.json file, which supports wildcards. If we delete it we have to restore all packages.  This file is listed as a child of project.json within Visual Studio.

ClassLibrary.xproj is the MSBuild file that defines what will happen when you build the project.
ClassLibrary.xproj.user overrides the Class­Library.xproj file and provides additional MSBuild properties such as local user debug-specific settings like ports.
Program.cs is used in  Console Application and ASP.NET Core Web Application (.NET Core) projects,it  defines a Program class that includes the definition of the Main entry point for your application even for Web applications.
Web.config : as usual, is used in Web applications and it  provides a minimal configuration for IIS but this file no longer contains app settings, which are instead moved into configuration files that are loaded by Microsoft.Extensions.Configuration. (see more details : https://msdn.microsoft.com/en-us/magazine/mt632279.aspx
Note that when we create a new project, all the source code are placed into a src subdirectory for the solution and for test projects , they are placed into a test directory alongside src.
Let's recapitulate : 

0 commentaires:

Enregistrer un commentaire