在本地调试 Nuget 包 [英] Debugging Nuget Package locally

查看:52
本文介绍了在本地调试 Nuget 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Visual Studio .net core api,它在我的解决方案中引用了一个基于 artifactory 的 nuget 包.nuget 包是一个 .net 核心类库.在我的本地,我有两个解决方案,即主要的 API 解决方案和类库解决方案.我想要完成的是,我希望能够在调试模式下运行 API 并中断我本地的类库代码中的方法调用,如果它甚至可能不更改周围的引用等,则几乎没有任何更改.在 API 中.尽量避免必须禁用 nuget 包并在解决方案中引用本地项目文件等.

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.

有没有办法做到这一点?我尝试在调试模式下启动 API 解决方案,然后进入类库项目附加到进程"并选择调试中的devenv.exe".我也尝试将 DLL 和 PDB 文件发布到与 API 相同的调试文件夹,但仍然没有破解代码.

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.

推荐答案

本地调试 Nuget 包

Debugging Nuget Package locally

要在本地调试nuget,您需要pdb 文件和编译文件(cs 资源文件),然后您就可以调试nuget 与他们两个.它与服务器完全不同.

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.

打包,可以将xxx.pdb打包为lib,将cs文件打包到nupkg文件中.所以它们都将在 nuget 包中恢复.

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>

然后cs文件将存在于Resource文件夹下,pdb文件将存在于文件夹下>lib 文件夹.

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

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

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

然后,将该包安装到主项目中,右键单击主解决方案-->属性-->常用属性-->Debug Source Files--> 将cs文件所在的文件夹路径添加到其中(解压并添加Resource文件夹的路径).

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 ) .

然后就可以在本地调试nuget包了.

And then you can debug the nuget package locally.

另外,你也可以参考这个类似的帖子 我之前解释过.

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

这篇关于在本地调试 Nuget 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆