You can debug the source code of asp.net core 2.0
in Visual Studio 2017. We must follow these steps:
If we have already downloaded Visual Studio 2017, we verify that our version is at least 15.3
(help → about Microsoft visual studio). If it is not, we update by clicking the yellow flag in the upper right corner. We may need to download the SDK version 2.0
separately.
After updating visual studio 2017, open a command prompt and we will dotnet --version
command to determine the current version of the SDK. If this is a version prior to version 2.0.0, we must also download the latest version of the SDK. We can also check any old installed versions of the SDK in C:\Program Files\dotnet\sdk
.
The necessary packages for the main branch in the source code of the asp.net kernel in github must be downloaded from the myget.org
repository. The nuget.org
repository is not suitable by default. So we go to tools -> nugget package manager -> package manager settings -> nugget package manager -> package sources
, and we click the plus (+) button to add two new repositories. The required package repository for the SDK is https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json
, and the package repository for the main branch is https://dotnet.myget.org/F/aspnetcore-master/api/v3/index.json
. We click update
for each new repository, and then OK
.
Let's github.com/aspnet
to github.com/aspnet
and suppose we want to debug the source code of MVC, we click on the MVC
link and then click on the releases
link. We are downloading release 2.0.0
with the tag rel/2.0.0
.
We unzip the file and go to the src
folder. In all project folders inside the src
folder, we must change the internal text of the <TargetFramework>
xml node in each of the *.csproj
files, from netstandard2.0
to netcoreapp2.0
. This change should be as follows:
<TargetFramework>netcoreapp2.0</TargetFramework>
We are creating a new asp.net core 2.0
project in Visual Studio 2017. We should pay attention to the choice of asp.net core 2.0
in the next window, because the default choice is asp.net core 1.1
.
choice asp.net core 2.0
In our newly created asp.net core 2.0
project, we need to add a link to the project in the {project_name}.csproj
. Right-click the project in the solution explorer and select edit {project_name}.csproj
. We will add the following XML text to it:
<ItemGroup> <ProjectReference Include="{mvc_solution_directory_path}\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" /> </ItemGroup>
{mvc_solution_directory_path}
is the path to the directory where we unzipped the source code from github and where the mvc.sln
file is mvc.sln
.
Now we need to add each of the projects located in the src
folder of the open source MVC
code. We right click our solution in the solution browser and select add -> existing project
.
We are ready to build our solution.
Trying to debug asp.net core 1.1
by downloading the appropriate open source version from github is quite problematic. I downloaded a small utility on github that automates steps 4-7. Hope this guide helps. I tested it on both Windows 7 and Windows 10, and I was able to debug open source.
source share