2013-06-17

Making the .NET Open Source More Open

NuGet has made obtaining libraries very simple. It would be awesome if the open source libraries that published to NuGet provided .pdb files in their packages that were source indexed to their source control provider. I tried it and it works really well for Autofac.

Autofac as an example

I was recently troubleshooting an issue that involved Autofac. It was installed in the project via NuGet. Since the package doesn't include the .pdb, I had to go to their website to download it. After that, I had to find and download the source that matched that build. I then have to tell Visual Studio where to find the source.

If the .pdb file was source indexed and included with the NuGet, Visual Studio would just download the source files as needed. It is possible to insert a source index into a .pdb file. I created this one for Autofac 3.0.2.

Use Your Source Control

It wasn't very easy to figure out how to create this, but it should be easy to copy. The spec is not very clear. Both http and https work. Autofac uses Mercurial from Google Project Hosting. Google Project Hosting, Bitbucket, and GitHub have raw interfaces that will work. Notably, I could not find a raw interface for CodePlex Git, but Subversion should work.

Code to Index

I learned a lot about the .pdb file structure when making this over the weekend. I created an F# script to create this. To verify that I was doing the source indexing correctly, the script verifies the MD5 checksums of the files to what is in the .pdb. The script uses Microsoft.Cci.Pdb, but since everything is marked internal, I had to make a several classes and members public to make this work. For the purposes of creating these indexes, I may abandon it and just write my own.

Tool Notes

Here are some tools I currently use to look at .pdb files, besides .NET code.

C:\Program Files (x86)\Windows Kits\8.0\Debuggers\x64\srcsrv
pdbstr and srctool

write srcsrc stream to pdb
pdbstr -w -s:srcsrv -p:Autofac.pdb -i:Autofac.pdb.srcsrv.txt 

read srcsrv stream from pdb
pdbstr -r -s:srcsrv -p:Autofac.pdb 

list all download urls from pdb
srctool -x Autofac.pdb

C:\Program Files (x86)\Microsoft Visual Studio 11.0\DIA SDK\Samples\DIA2Dump\
copy somewhere else, open dia2dump.sln, build, and add Debug\bin to path

list all files names in the pdb
dia2dump -f Autofac.pdb

Community Effort

It would definitely make my job easier. I'd really like to see important open source projects like ASP.NET, EntityFramework, and FSharp.Core source indexed. I can't find .pdb files that match the latest stable releases of the first two. For FSharp.Core, I need a .pdb that doesn't strip out the file names like all of them do from http://msdl.microsoft.com/download/symbols.

What do you think? Is this a good idea?