简体   繁体   English

本地调试 Nuget Package

[英]Debugging Nuget Package locally

I have a visual studio .net core api that references a artifactory based nuget package within my solution.我有一个视觉工作室 .net 核心 api 引用了一个基于工件的 nuget ZEFE90A8E604A7C8B70E 内的解决方案。 The nuget package is a .net core class library. nuget package 是 .net 核心 ZA2F2ED4F8EBC2CBB4C21A29DC40AB6 库。 On my local I have both solutions the main API solution and the class library solution.在我的本地,我有两种解决方案,主要的 API 解决方案和 class 库解决方案。 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.我想要完成的是我希望能够在调试模式下运行 API 并闯入 class 库代码中的方法调用我有本地几乎没有任何变化,如果它甚至可能没有改变周围的引用等。在 API 中。 Trying to avoid having to disable the nuget package and reference the local project file in the solution etc.尽量避免必须禁用 nuget package 并在解决方案等中引用本地项目文件。

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.我尝试的是在调试模式下启动 API 解决方案,然后我将 go 放入 class 库项目“附加到进程”并选择调试中的“devenv.exe”。 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.我还尝试将 DLL 和 PDB 文件发布到与 API 相同的调试文件夹中,但仍然没有破坏代码。

Any suggestions is there a way to handle this local?有什么建议可以处理这个本地的吗? Hope this makes sense.希望这是有道理的。

Debugging Nuget Package locally本地调试 Nuget Package

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.要在本地调试 nuget ,您需要pdb文件和编译文件(cs 资源文件),然后您可以使用这两个文件调试 nuget。 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.要打包它,可以将xxx.pdb为 lib 并将 cs 文件打包到 nupkg 文件中。 So both of them will restore in the nuget packages.所以它们都将在 nuget 包中恢复。

In your net core class library project, use these:在您的网络核心 class 库项目中,使用这些:

<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.然后cs文件将存在于Resource文件夹下, pdb文件将存在于lib文件夹下。

在此处输入图像描述

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

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 ).然后,在主项目中安装package,右键主解决方案-->属性-->通用属性-->调试源文件-->添加cs文件所在的文件夹路径(解压package 并添加路径(如果资源文件夹)。

And then you can debug the nuget package locally.然后就可以在本地调试 nuget package。

In addition , you can also refer to this similar thread which I explained before.另外,你也可以参考我之前解释过的这个类似的线程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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