简体   繁体   English

调试Nuget包不起作用

[英]Debugging Nuget package doesn't work

I'm trying to create a debugger nuget package. 我正在尝试创建一个调试器nuget包。 So, I start with "Creating symbol packages" . 所以,我从“创建符号包”开始 Create package using nuget pack PackageARM.nuspec -Symbols 使用nuget pack PackageARM.nuspec -Symbols创建包

PackageARM.nuspec: PackageARM.nuspec:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata>
    <id>PackageARM</id>
    <version>1.0.15</version>
    <authors>PackageARM</authors>
    <owners>PackageARM</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Package Description</description>
    <dependencies>
      <group targetFramework=".NETStandard2.0" />
    </dependencies>
  </metadata>
  <files>
        <file src="bin\Release\netstandard2.0\*.pdb" target="lib\netstandard2.0" />
        <file src="bin\Release\netstandard2.0\*.dll" target="lib\netstandard2.0" />
        <file src="**\*.cs"  target="src" />
    </files>
</package>

And push it to nuget: https://www.nuget.org/packages/PackageARM/1.0.15 并将其推向nuget: https ://www.nuget.org/packages/PackageARM/1.0.15

Then uncheck Enable Just My Code and check Enable source server support in VS 2017. Also I tried to add symbol servers: https://www.nuget.org , https://nuget.smbsrc.net/ but no result. 然后取消选中Enable Just My Code并选中在VS 2017中Enable source server support 。此外,我尝试添加符号服务器: https//www.nuget.org,https//nuget.smbsrc.net/但没有结果。

When I try step into method from package using F11 it just step to the next line. 当我尝试从包使用F11进入方法时,它只是步骤到下一行。 What I missed? 我错过了什么?

My pdb file contains path to .cs file that is 'C:\\project\\ProjectARM\\Class1.cs' it is ok? 我的pdb文件包含.cs文件的路径,即'C:\\ project \\ ProjectARM \\ Class1.cs'可以吗? how can other users debug if the doesn't have that path with source? 如果没有源路径,其他用户如何调试?

how can other users debug if the doesn't have that path with source? 如果没有源路径,其他用户如何调试?

Since you could not access the symbols package from the symbols server, we could not debugging on that way. 由于您无法从符号服务器访问符号包,因此我们无法以这种方式进行调试。 I would like provide you a workaround to debugging the nuget package. 我想为您提供调试nuget包的解决方法。

  1. Put the pdb and source code file in the NuGet package alongside the dll. 将pdb和源代码文件放在与dll一起的NuGet包中。
  2. Add the source code to the Debug Source Files for the solution that references the package. 将源代码添加到调试源文件中以获取引用该包的解决方案。

More detail on step 1: 第1步的更多细节:

I have checked your nuget package on the nuget.org, found that you have already put the .pdb and source code file in the NuGet package alongside the .dll . 我在nuget.org上检查了你的nuget包,发现你已经将.pdb和源代码文件放在了.dll旁边的NuGet包中。

More detail on step 2: 第2步的更多细节:

When you have a solution open, right click on Solution, select Properties...Common Properties...Debug Source Files, and add the root source directory for the relevant binary reference (Add the path of .cs file in the Packages folder after install the nuget package): 打开解决方案后,右键单击Solution,选择Properties ... Common Properties ... Debug Source Files,然后添加相关二进制引用的根源目录 (在Packages文件夹中添加.cs文件的路径)安装nuget包):

在此输入图像描述

For some more details, please check this thread . 有关更多详细信息,请查看此主题

I've struggled with this for a long time. 我很长时间都在努力。 Here's the easiest way that I found that works repeatably: 这是我发现可重复工作的最简单方法:

  • Acquire the source code and build a nuget package locally. 获取源代码并在本地构建nuget包。 You'll need to increment to package version. 您需要增加到包版本。 Hopefully the author has provided a .nuspec to make building easier. 希望作者提供了一个.nuspec来使构建更容易。

Create a local nuget source: 创建本地nuget源:

  • Place the .nuget file that you just created in C:\\Nuget (for example) 将您刚刚创建的.nuget文件放在C:\\ Nuget中(例如)

  • In Visual Studio, select Tools / Options / Nuget Package Manager / Package Sources 在Visual Studio中,选择“工具/选项/ Nuget包管理器/包源”

  • Press the green (+) icon. 按绿色(+)图标。 Add the path to the local nuget package that you created above (C:\\Nuget) and move the package source to the top of the list. 将路径添加到上面创建的本地nuget包(C:\\ Nuget),并将包源移动到列表顶部。

  • In your solution, for each project, remove the previous reference to the external nuget package and add the new nuget package from your local nuget source. 在您的解决方案中,对于每个项目,删除先前对外部nuget包的引用,并从本地nuget源添加新的nuget包。

  • Start debugging and you should be able to step into the code for the nuget package. 开始调试,您应该能够进入nuget包的代码。

I'm able to set a breakpoint in the source code from where I build the nuget package and have it break when I run the code. 我能够在源代码中设置一个断点来构建nuget包,并在运行代码时将其断开。

All of the steps above are a little fidgity and you may need to play with it a few times to get it to work. 上面的所有步骤都有点狡猾,你可能需要玩几次才能让它发挥作用。

Let me know in the comments if this works for you. 如果这对您有用,请在评论中告诉我。 And if so, I'd appreciate an upvote! 如果是这样,我会欣赏一个upvote! :) :)

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

相关问题 为什么 NuGet 包 NLog 不适用于 .NET Core? - Why doesn't NuGet package NLog work for .NET Core? Nuget软件包(StyleCop.Analyzers)在重新加载项目时不起作用 - Nuget Package (StyleCop.Analyzers) doesn't work on project reload 本地调试 Nuget Package - Debugging Nuget Package locally NuGet安装软件包不起作用。 如何获取更多详细信息以帮助调试为什么失败? - NuGet install-package doesn't work. How can I get more verbose information to help debug why this is failing? 我有一个 class 库,我在其中添加了 UwpDesktop nuget package。 相同的 nuget 在 Windows 形式中工作正常,但在 class 库中不起作用 - I have a class library in which I added UwpDesktop nuget package. Same nuget works fine in Windows form but doesn't work in class library WIX自定义操作调试不起作用 - WIX custom action debugging doesn't work 我的NuGet软件包在使用它作为依赖项的项目中似乎没有更新 - My NuGet package doesn't seem to update in projects that use it as a dependency c# nuget 包没有出现在 VS 的引用中 - c# nuget package doesn't show up in references in VS Nuget软件包(nupkg)是否与项目的最新更改不同步? - The Nuget package (nupkg) doesn't sync with the project latest changes? 为什么Nuget软件包不只包含引用的项目? - Why doesn't Nuget package contain only referenced projects?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM