How to debug using Nuget source code

北城余情 提交于 2019-12-22 00:35:06

问题


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.

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>

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.

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.

Edit: 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.


回答1:


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.



来源:https://stackoverflow.com/questions/26972844/how-to-debug-using-nuget-source-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!