In the past renditions of ASP.NET.

In the past renditions of ASP.NET.

It was conceivable to troubleshoot certain parts of the structure stack yet setting up the improvement environment and ordering all the doubles was not the most straightforward assignment. ASP.NET 5 progressions that and makes investigating structure code as simple as troubleshooting your own application.

Before getting into the How-To part, there is one restriction that you need to comprehend: you should not blend distinctive renditions of the runtime and/or bundles. Attempting to troubleshoot the most recent MVC bundles utilizing an old runtime may be conceivable however there is no ensure that it will work, or attempting to utilize Beta2 and Beta3 bundles as a part of the same application can prompt some extremely interesting aggregation mistakes. The suggestion is that in the event that you utilize a BetaX (X = number) bundles, X must be the same for all bundles and runtime, while on the off chance that you utilizing the most recent advancement bits everything must be from the improvement extensions/bolster.

When you make another ASP.NET 5 application and investigate it you will recognize that, as in the past variants, you are not ready to venture into system code. On the off chance that you take a gander at the modules that are stacked, you can see which of them have their images stacked and which not. Also, you can see from where every module was stacked. (To open the Modules window while in an investigate session explore to Debug -> Windows -> Modules).

6114.before_project_debug

How to get the source code for ASP.NET

For this blog entry, I am going to utilize MVC as the system segment being fixed. MVC and whatever is left of the ASP.NET 5 system parts are accessible in GitHub. To get the source code for MVC, you need to clone the MVC store (downloading it as a zip file does not suffice in light of the fact that the labels are excluded, all the more on that in the following section).

D:\debug>git clone https://github.com/aspnet/mvc
Cloning into 'mvc'...
remote: Counting objects: 24774, done.
remote: Compressing objects: 100% (5542/5542), done.
remote: Total 24774 (delta 18951), reused 24354 (delta 18617)
Receiving objects: 100% (24774/24774), 6.91 MiB | 3.40 MiB/s, done.
Resolving deltas: 100% (18951/18951), done.
Checking connectivity... done.
Checking out files: 100% (2072/2072), done.

At the outset of the article, I specified that you must have matching bundles and source code. You can see in Visual Studio that all the bundles are from the Beta2 discharge. When you clone an ASP.NET GitHub vault, it defaults to the dev limb. That is fine on the off chance that you are utilizing the most recent bundles and runtime from thech dev sustain, or in the event that you aggregate everything yourself. Else, you will need to synchronize to the submit comparing to those bits. When we have a real discharge (Beta1, Beta2, and so forth.) we tag the specific submit that was utilized to create the bits. Utilizing the git label order, you can see the accessible labels:
D:\debug>cd mvc
D:\debug\mvc>git tag
6.0.0-alpha2
6.0.0-alpha3
6.0.0-alpha4
6.0.0-beta1
6.0.0-beta2
As the tag name suggests, the Beta2 bits correspond to the 6.0.0-beta2 tag. Sync to that tag using the git checkout <tagname> command:
D:\debug\mvc>git checkout 6.0.0-beta2
Note: checking out '6.0.0-beta2'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at 2a57f93... Updating Razor to not use K.Roslyn

Now that we have the sources for the packages used by the application, we can configure the application to use them.

Using the local source code instead of the official binaries

In ASP.NET 5 the unit of deployment is the NuGet package. Also, ASP.NET 5 uses Roslyn under the hood and it is able to compile source code on the fly, without requiring the user to provide binaries compiled a priori.

When you want to debug into the source of another library, you specify where the source code for the package containing that library is. If the runtime finds a valid project, it will use it instead of the actual package coming from NuGet or MyGet. An ASP.NET 5 solution, has a global.json file in the root folder. Inside this file, you can specify where the runtime should look for source code. By default it only looks at the src and test folders belonging to the solution.

To use the MVC code downloaded earlier, you have to add the path to MVC’s src folder in global.json. That’s it, now you can debug MVC! Just run the run the application. Remember to revert the changes to global.json, especially absolute paths, before checking in to source control.

6254.after_global_edit_2

The content of the global.json file:

{
  "sources": [
    "src",
    "test",
    "d:/debug/mvc/src"
  ]
}

The runtime chooses which bundle to load utilizing a credulous calculation. At the point when a NuGet reliance (a bundle) is stacked:

1. On the off chance that any of the source code areas pointed out in global.json contains an organizer with the same name as the bundle (e.g. Microsoft.AspNet.Mvc) and that envelope contains a record named project.json, it will utilize that organizer and the source documents inside it.

2. Something else, the assembled double from the bundles organizer is stacked.

After you add the way to MVC’s source code, you will see that Visual Studio naturally adds the MVC undertakings to your answer. Likewise, on the off chance that you take a gander at your venture’s references hub, you will recognize that Microsoft.AspNet.Mvc has an alternate symbol and it demonstrates that it was stacked from an alternate area:

2273.after_solution

In the event that you begin troubleshooting and take a gander at the stacked modules, you will recognize that Microsoft.AspNet.Mvc is no more stacked from the bundles envelope and that images are presently accessible:

4174.after_project_debug

Behind the scene, MVC was aggregated from sources when the application began and the came about pairs were utilized.

Presently, the time it now, time to investigate. Include a break point anyplace in the MVC code and it ought to be hit when the code is executed:

2867.actual_debugging

In the event that you are not yet amped up for this astonishing new gimmick, let me include a reward capacity. On the off chance that you change the MVC code in one of the ventures added to the arrangement and restart the application, it will utilize the changed MVC. Proceed, attempt it! In the event that you alter an issue or enhance the structure, you can even send a force solicitation (see the contributing rules for more data).

Troubleshooting

We know that sometimes things don’t work as smooth as described here. Below are the most common mistakes that we have seen:

1. You are utilizing advancement bundles with old bits.Look at the venture References hub and verify that all bundles have the same adaptation if utilizing discharged bits.

2. You are utilizing a more seasoned/fresher runtime. Utilizing the kvm order line apparatus (introduced independently from the Home vault), you can see which form of the runtime you are utilizing. kvm rundown will indicate which form is at present dynamic (the one marker with *). You can choose an alternate runtime rendition than the dynamic one, for a specific undertaking, from the Project Properties page in Visual Studio.

D:\debug\mvc>kvm list

Active Version     Runtime Architecture Location                        Alias
------ -------     ------- ------------ --------                        -----
       1.0.0-beta2 CLR     amd64        C:\Users\victorhu\.kre\packages
  *    1.0.0-beta2 CLR     x86          C:\Users\victorhu\.kre\packages default
       1.0.0-beta2 CoreCLR amd64        C:\Users\victorhu\.kre\packages
       1.0.0-beta2 CoreCLR x86          C:\Users\victorhu\.kre\packages

3. Global.json is not really indicating the right sources. Verify the way in global.json is indicating a cloned storehouse. Additionally, perceive that it is simplest to use forward cuts (/) on the grounds that they deal with all stages. In the event that you utilize oblique punctuation lines (\) you need to rather utilize twofold oblique punctuation lines (\\) as catalog separator, and it will work just on Windows.

 

 

No Comments

Sorry, the comment form is closed at this time.