Visual Studio使用已下载的微软.NET源代码

前几天看到园子里有位仁兄告之使用NetMassDownloader下载.NET源代码(原帖在这里:http://www.cnblogs.com/shanyou/archive/2008/02/15/netmassdownloader.html),于是也尝试了一下,果真把Source都下了下来,可是该怎么使用,网上倒是有不少线程的教程,虽然都是E文,但是很简单。

To use the .NET Reference Source with Visual Studio 2005/2008, you would need to do the following three additional steps. The first is in the Options dialog for Visual Studio, Debugging, Symbols property page. In the “Symbol file (.pdb) locations” list box, you would add “c:\ReferenceSource” like the following.


The second setting is in Options dialog, Debugging, General property page, uncheck Require source files to exactly match the original version.(注意:这里如果已经下载源代码到本地了,就应该把Enable source server support选项不选中,这样可以加快debug时的检索速度)


The final step you’ll have to do in each solution where you want to access the downloaded .NET Reference Source Code, you’ll go into the solution property pages, Common Properties, Debugging Source Files, and add C:\ReferenceSources to the top of the “Directories containing source code” list box as follows:

Visual Studio 2005/2008 will automatically do the right thing and replace the first directory of every source file it finds in a PDB file with c:"ReferenceSource. With the automation model in Visual Studio 2005/2008, I’m sure you could wipe up a macro to automatically set that path in the solution.

这个方法可以使用,但是略显麻烦。经过一段业余时间研究,发现有个容易的办法:
第一和第二个设置没得说,就那么设置就可以了。第三条设置可以通过修改注册表,简化操作。
如果你的IDE是VS2005:
在HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0下面有一个Key叫Source Directories,把你的本地源代码路径添到最前并以分号(;)结尾即可。
如果你的IDE是VS2008,那么这个注册表位置在HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0,其他一样。
完成之后,你只需要把工程文件所在目录的*.suo文件(suo文件是工程文件的配置缓存文件,起加速载入作用,删除之后打开工程IDE会自动创建新的缓存)删除即可。

另外,Colin告诉我,如果你的系统是Vista并且硬盘有个分区叫F,那么你还可以通过创建文件夹link来建立快捷使用方式:

mklink -d f:\redbits c:\ReferenceSource\redbits

update at 2008/02/20 13:40:
1、感谢Colin指出错误,已更正。
2、感谢shanyou的补充说明——Source Reference需要你自己同意MS-PL协议才能看代码的,所以别人是不能通过邮件方式给你发送的
3、本文仅适用于已经下载了Source。
4、请注重版权和授权。

 

posted @ 2008-02-20 11:46  winkingzhang  阅读(6533)  评论(16编辑  收藏  举报