如何使用Nuget源代码进行调试 [英] How to debug using Nuget source code

查看:121
本文介绍了如何使用Nuget源代码进行调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为一个临时解决方案(直到我们获得内部Symbol服务器设置),我试图构建包含DLL所有源代码的Nuget程序包,以便我们的用户可以调试其代码.

As a temporary solution (until we get an internal Symbol server setup), I am trying to build Nuget packages that include all source code for the DLL so that our users can debug its code.

我已经构建了以下Nuspec文件

I have build the following Nuspec file

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
    <metadata>
        <id>My Assembly</id>
        <version>1.0.0</version>
        <title>My Assembly</title>
        <authors>Me</authors>
        <owners>Me</owners>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>My description</description>
        <copyright>© Me 2014</copyright>
          <dependencies>
            <dependency id="Autofac" />
            <dependency id="Autofac.Configuration" />
            <dependency id="Autofac.Web"/>
            <dependency id="AutoMapper" />
            <dependency id="FluentNHibernate" />
            <dependency id="Iesi.Collections"/>
            <dependency id="Newtonsoft.Json" />
            <dependency id="NHibernate"/>
        </dependencies>
          <frameworkAssemblies>
  <frameworkAssembly assemblyName="System.Web" />
</frameworkAssemblies>
    </metadata>
   <files>
    <file src="bin\MyAssembly.dll" target="lib" />
    <file src="bin\MyAssembly.pdb" target="lib" />
    <file src="**\*.cs" target="src"/>
  </files>          
</package>

当我添加构建此Nuspec文件时,最终得到一个不错的包,包括我的DLL,以及一个名为src的文件夹,其中包含源代码.

When I add build this Nuspec file I end up with a nice package including my DLL, plus a folder called src containing the source code.

我看不到怎么做,是在通过引用的DLL调试时让Visual Studio使用src目录中的.cs文件(我目前得到的只是一个分解的预览).我以为应该是这样,但是我找不到如何执行此操作的任何示例.

What I can't see how to do is to get Visual Studio to use the .cs files in the src directory when debugging by referenced DLL (all I currently get is a dissembled preview). Is this possibly, I assume it should be, however I can't find any examples of how to do this.

感谢您接受答案.请注意,我发现的另一种方法是在使用解决方案的公共属性"->调试源文件"列表中为Nuget包添加"src"文件夹.

Thanks for the accepted answer. Just to note, the other way I found of doing this is to add the 'src' folder for the Nuget package in the consuming solutions Common Properties -> Debug Source Files list.

推荐答案

在运行程序时,您可以打开调试|模块"窗口.从那里,您可以选择DLL并浏览以找到相应的PDB文件.之后,您可以手动打开源CS文件并在其中设置断点. Visual Studio将验证PDB和CS是否与已编译的CS文件相对应,但这应该没问题,因为您将它们打包在一起.

While you are running your program, you can bring up the Debug|Modules window. From there, you can select the DLL and browse for the corresponding PDB file. After that, you can manually open the source CS file and set breakpoints in it. Visual Studio will verify if the PDB and CS correspond to the compiled CS file, but that should be alright since you package them together.

这篇关于如何使用Nuget源代码进行调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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