Introduction
In today’s discussion, we’ll delve further into some more interesting features on ASP.NET 5. So, let's begin the show. Now, let’s talk about the different CLR Types available with this project. So, when I talk about different CLRs; there are actually 2 versions of CLRs. The first one is the usual one which has the full blown version of CLR which we have been using since its inception. Another one is the minimized version or also known as cloud optimized version of CLR. Now, let’s go ahead and check project settings.
As you can see in the above screen shot; my default setting is against full blown CLR which is running on the X86 machine. Now, if you see the drop down shown below, you will notice that I also have the option for cloud optimized version.
Now, let’s change the environment to cloud version and then run the app and inspect the output of the greet controller which we created in the 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 in 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 have one to one mapping with assemblies. But, you can also have multiple modules per assembly. Now, this module window is showing me what all modules are loaded in the application.
Now, one point to note here is that all these modules are coming from one location that is from user’s location as highlighted above. Let’s jump to this location for a minute and inspect the same.
Now, when I go inside there; I can see that there is nuget package file or NUPKG file which is around 14 MB.
This is complete Core CLR. Can you imagine? Now, what I can do is I can simply take this file and copy to a different system my .NET Core version is ready. This bin directory here is the extracted version of this nuget package as shown in the below screen shot:
Also, when you go to the runtime folder and go to full blown CLR folder as shown below,
you will notice that size of the NUPKG file is very less compared to Core CLR version. Confused?
In case of full blown CLR, all components get loaded from GAC (Global Assembly Cache) not from here. But, it doesn’t mean that there is no centralized repository for Core CLR. So, if you go to the below location; you will find 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. So, ASP.NET 5 completely embraces nuget package. We manage dependencies via nuget package. We can have CLR stored through 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 different project dependencies also listed here within the same solution. For example, let’s go ahead and add class library project to the solution folder. Make sure you install Vnext version of class library which means this class library project can have all the flexibilities of dynamic compilation that we have been using so far.
Once you added the project, your solution will look like shown below. So, even the new project gets added under the src folder.
You will also notice that this new class library project also added new project.json file which also lists the dependencies accordingly for running Class library project.
Now, if I have to use this project in my web project; then I just need to include this newly created project in the dependencies section of project.json file of 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 the same in Greet controller.
With this, I will wrap this session. In the next section, we’ll delve further into new features of ASP.NET 5. Till then stay tuned and happy coding.
Thanks,
Rahul Sahay
83 total views, 79 views today