简体   繁体   中英

Debugging Nuget Package locally

I have a visual studio .net core api that references a artifactory based nuget package within my solution. The nuget package is a .net core class library. On my local I have both solutions the main API solution and the class library solution. What I am trying to accomplish is I want to be able to run the API in debug mode and break into the method call in the class library code I have local with little too no changes at all if its even possible without changing references around etc. in the API. Trying to avoid having to disable the nuget package and reference the local project file in the solution etc.

Is there anyway to accomplish this? What I tried was I start up the API solution in debug mode then I go into the class library project 'Attach to Process' and pick the 'devenv.exe' that is in debug. I also tried like publishing the DLL and PDB file to the same debug folder as the API but still does not break into the code.

Any suggestions is there a way to handle this local? Hope this makes sense.

Debugging Nuget Package locally

To debug a nuget locally , you should need the pdb file and compile files (cs resource files) and then you can debug the nuget with both of them. It is quite different from the server.

To pack it , you can pack the xxx.pdb as lib and pack cs files in the nupkg file. So both of them will restore in the nuget packages.

In your net core class library project, use these:

<ItemGroup>
    <None Include="$(OutputPath)ClassLibrary.pdb" Pack="true" PackagePath="lib\$(TargetFramework)"></None>
 <Compile Update="Class1.cs" Pack="true"  PackagePath="Resource">
</ItemGroup>

Then , the cs files will exist under Resource folder and the pdb file will exist under lib folder.

在此处输入图像描述

========================

Then, install that package in a main project, right-click on the main solution--> Properties --> Common Properties --> Debug Source Files -->to add the folder path which the cs files exist into it(unpack the package and add the path if Resource folder ).

And then you can debug the nuget package locally.

In addition , you can also refer to this similar thread which I explained before.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM