Hi Friends.

In today's discussion, we'll delve further into some more interesting features of ASP.NET 5. So, let's begin the show. Now, let's talk about the various CLR Types available with this project. So, when I talk about the various CLRs, there are actually 2 versions of CLRs. The first one is the usual one that has the complete version of the CLR that we have been using since its inception. Another one is the minimized version, also known as the cloud-optimized version, of the CLR. Now, let's go ahead and check the project settings.



As you can see in the preceding screen shot, my default setting is against the complete CLR that is running on the X86 machine. Now, if you see the drop down shown below, you will see that I also have the option for the cloud-optimized version.



Now, let's change the environment to the cloud version and then run the app and inspect the output of the greet controller that we created in a previous section. It should print my name there.



Now, let's go ahead and debug this controller. So, now when I refresh the page it will hit the breakpoint as shown below.



Here, when I go to the modules section as shown below in the screen shot, it will list the complete flow. So, here you can see from where all the binaries are loading. Basically modules are nothing but something with a one-to-one mapping with assemblies. But you can also have multiple module per assembly. Now, this module window is showing me what all the modules are that are loaded into the application.





Now, one point to note here is that all these modules are coming from one location, that is from the user's location, as highlighted above. Let's jump to this location for a minute and inspect it.



Now, when I go inside there, I can see that there is a Nuget package file (NUPKG file) that is around 14 MB.



This is the complete Core CLR. Can you imagine? Now, what I can do is I can simply take this file and copy it to another system and then my .NET Core version is ready. This bin directory here is the extracted version of this Nuget package as shown in the following screen shot.



Also, when you go to the runtime folder and go to the complete CLR folder as shown below.



You will see that the size of the NUPKG file is much smaller compared to the Core CLR version. Confused?


In the case of the complete CLR, all components are loaded from the Global Assembly Cache (GAC), not from here. But it doesn't mean that there is no centralized repository for the Core CLR. So, if you go to the following location then you will find the packages folder.



So, now this will be the centralized repository for your Core CLR.

So, whenever, we install any dependencies it will sit here in this packages folder. Hence, ASP.NET 5 completely embraces the Nuget package. We manage dependencies via the Nuget package. We can have the CLR stored using the Nuget package. Hence, these packages folders are referred to as Global Package Cache.

Now, project.json is not only used to have the Nuget dependencies only. We can have various project dependencies also listed here within the same solution. For example, let's go ahead and add a class library project to the solution folder. Make sure you install the Vnext version of the class library, which means this class library project can have all the flexibilities of dynamic compilation as in what we have been using so far.



Once you have added the project, your solution will look as shown below. So, even the new project gets added under the src folder.



You will also see that this new class library project has also added a new project.json file that also lists the dependencies accordingly for running the Class library project.



Now, if I need to use this project in my web project then I just need to include this newly created project in the dependencies section of the project.json file of the web project as shown below.



Now, when you don't provide the version name against the package or project it will pull the latest one. Let's go ahead and create some method in the class library project to return some meaningful thing.



Let's use it in the Greet controller.


With this I will wrap up this session. In the next section we'll delve further into the new features of ASP.NET 5. Until then stay tuned and Happy Coding.

Thanks,

Rahul Sahay

Happy Coding.

Next Recommended Readings