Click here to Skip to main content
15,860,844 members
Articles / Desktop Programming / Win32

.NET Mass Downloader - Download the .NET Framework Source Code

Rate me:
Please Sign up or sign in to vote.
4.84/5 (47 votes)
26 Apr 2010Apache12 min read 318.7K   1.7K   154   68
With this tool you can download whole .NET Framework source code at once, and enjoy offline browsing. With it, you can have whole the source code without any Visual Studio product installed

Downloads

Introduction

Update 26.04.2010 (Please Download The Latest Version From The Codeplex )

I have release a new version 1.6.0.0 which has the following features

  • General Support For Extraction Of .Net 4.0 And VS2010 Support Added.
  • The source file targets are now extracted from srvsrc files and no longer hard-coded.
  • The supported VS Versions are added to the config file and can be extended without changing the source code.
  • General Code Cleanup Applied.
  • Solution File is Upgraded To VS2008 and a VS2010 Solution File Added.

Update 31.08.2008

I have released a new version 1.5.0.1 which fixes the following bugs.

  • Support For VS2008 SP1 Source download added , you can now download the source codes for Framework 3.5 SP1.
  • Corrupt or zero byte pdb files no longer causes program to crash
  • Missing srvsrc file no longer causes null reference exceptions
  • SrvSrc file extractor added to the project source code for persons interested

Update 29.08.2008

I have released a new version 1.4 which has the following features.

  • Support For VS2008 SP1 Source download added , you can now download the source codes for Framework 3.5 SP1.

Update 27.06.2008

I have released a new version 1.3 which has the following features.

  • Allow to process DLL or EXE files in sub-folders recursively (in addition to the top directory).
  • Allow to cleanup temporary compressed *.pd_ files.
  • Allow to download retail symbols for native DLL or EXE files from the Microsoft Symbol Server (msdl.microsoft.com) (by setting UseReferenceSourceServer to "false" in NetMassDownloader.exe.config).
  • Make the URLs of the symbol servers configurable in NetMassDownloader.exe.config.
  • Allow to specify whether to download only symbols without source code via the setting DownloadSourceCode ("true" by default) in NetMassDownloader.exe.config.
  • Use the original date-time of files from the server if available.
  • Download is now asynchronous; the download progress can be seen for each file (symbol or source code).
  • Improve the console output. It is less verbose and now easy to read.
  • Allow to resume download remaining source code files for an existing symbol file (by setting SkipExistingSourceFiles to "true" (default value) in NetMassDownloader.exe.config).

Whole these features can be controlled via the NetMassDownloader.exe.config file.

Update 21.05.2008 : A Windows Client which automatically does the steps required after download will be available in a few days. Please check out. Please send me whole your wishes in the project page, so i can include them in the next release.

Update : Proxy Support has been improved. Please get the latest version if you are having download problems with authenticated proxies.

Welcome to the .NET Mass Downloader project. While it’s great that Microsoft has released the .NET Reference Source Code, you can only get it one file at a time while you’re debugging. If you’d like to batch download it for reading or to populate the cache, you’d have to write a program that instantiated and called each method in the Framework Class Library. Fortunately, .NET Mass Downloader comes to the rescue!

The tool which enables offline debugging in VS2008 , VS2008 Express Edition ,VS2005 And Codegear Rad Studio.

The only thing you need to use this tools is having .NET Framework 3.5 RTM installed. With it, you can have whole the source code without any Visual Studio Product installed. If you are using Vista, please check that you are running under administrative permissions.

Background

As you all know the .NET Framework 3.5 Source Code has been made public via Visual Studio 2008 with the install of a small addin a few weeks ago.

The actual short coming of the tool was, that it didn't support the download of the whole framework code at once, nor it has been downloading each source file for a class one by one. Also because of each time downloads it was not possible to use this feature offline , so no offline debugging was possible.

It was also not possible to use this nice feature in VS2005 and VS2008 Express Editions.

Our tool enables you to use whole this missing features.

Some small note from John Robbins Blog About Our Project:

Kerem Kusmezer contacted me and said that he'd been hacking around with Fiddler and figured out how to download the PDBs and code from Microsoft.

He asked if I I'd be interested in helping him develop the utility and I don't think I ever wrote a response faster in my life!

Kerem had already started a discussion with Shawn Burke about the legality of producing a source downloader and once we got back a very encouraging "go for it" we got to work.

All the credit for the tool belongs to Kerem Kusmezer.

He did all the really hard work of figuring out the HTTP downloads ,the PE file processing, and PDB Stream Extraction.

I did the console driver, a lot of testing, and sat around amazed at how much work Kerem could accomplish in very short periods of time.

I really appreciate that Kerem let me work on the project with him and being his code monkey.

Prerequisites:

When you first run Net Mass Downloader, you will be prompted with the current EULA for accessing the source code. If you don’t agree with the Microsoft EULA, clicking the Decline button will not download the source code.

You must install the RTM Version of the .NET Framework 3.5 to access the source codes even if you are using VS2005.

Using the code

The tools has been implemented as a commandline application , which shows the following help screen after you execute it.

netmassnewscreen.PNG

The only required arguments are –file or –directory, both of which can be specified as many times as you’d like. When you specify a directory, only the .DLL and .EXE files from that directory will be processed. If you wanted to download all the source code from binaries in the .NET 2.0 32-bit and 64-bit directories, the command line you’d pass is:

-d C:\Windows\Microsoft.NET\Framework\v2.0.50727 –d C:\Windows\Microsoft.NET\Framework64\v2.0.50727

The main purpose of Net Mass Downloader is to populate the source code download cache for debugging, the default download location is the cache you specified to Visual Studio 2008. We put in the –vsver switch to account for future Visual Studio versions so Mass Downloader could work with future CTPs and versions.

While it's great to see the .NET Reference Source Code in Visual Studio 2008, there are a lot of developers out there who can't upgrade yet.

VS2005 Setup For NetMassDownloader

Initially, we went down the path of seeing if we could patch the PDB files so Visual Studio 2005 users could have access to the .NET Reference Source Code. After a lot of hassle, we realized that there was a much easier way. If you specify the –output switch, we will put the PDB and the source code into that directory using the build paths instead of the source server paths. Thus, if your command line to NetMassDownloader.exe is –d C:\Windows\Microsoft.NET\Framework\v2.0.50727 –output c:\ReferenceSource, the PDB files are put in C:\ReferenceSource as well as the source files.

To use the .NET Reference Source with Visual Studio 2005, 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.

020608_0256_DownloadAll1.png

The second setting is in Options dialog, Debugging, General property page, uncheck Require source files to exactly match the original version.

020608_0256_DownloadAll2.png

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:

020608_0256_DownloadAll3.png

Visual Studio 2005 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, I'm sure you could wipe up a macro to automatically set that path in the solution.

VS2008 Express Edition Setup

Initially, we went down the path of seeing if we could patch the PDB files so Visual Studio 2005 users could have access to the .NET Reference Source Code. After a lot of hassle, we realized that there was a much easier way. If you specify the –output switch, we will put the PDB and the source code into that directory using the build paths instead of the source server paths. Thus, if your command line to NetMassDownloader.exe is –d C:\Windows\Microsoft.NET\Framework\v2.0.50727 –output c:\ReferenceSource, the PDB files are put in C:\ReferenceSource as well as the source files.

To use the .NET Reference Source with Visual Studio 2008 Express Edition, 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.

First be sure that "Require source files to exactly match the original version" is not checked in VS2008 Options -> Debugging -> General Dialog:

20081.PNG

After that check the check box Show all settings which is at the left down of the screen.

If show all settings has been checked, the screen will look like the following:

20082.PNG

There please goto the Symbols location , add the target path that you give out in the -output directory there. For example we assume you used the following commandline arguments to execute NetMassDownloader

netmassdownloader.exe -d c:\winnt\microsoft.net\framework\v2.0.50727 -output c:\cachetest -v

You will see a similar window like this:

downloadprogress.PNG

Just write the output directory c:\cachetest as above to the symbols dialog.

Only one step is left after that, you can enjoy debugging the .net framework under VS2008 Express Edition.

Just open a new solution in VS2008 Express Edition, go to the Solution Properties Dialog, add the above mentioned directory to it like below.

20083.PNG

Now you can debug with F11 into the source code of .net framework offline from your VS2008 Express Edition.

Additional Notes

When you first run Net Mass Downloader, you will be prompted with the current EULA for accessing the source code. If you don't agree with the Microsoft EULA, clicking the Decline button will not download the source code. While you might be tempted to remove the EULA check, I would strongly recommend that you not do so as Microsoft has said that they may change the EULA at any time. The last thing you want to do is get caught with a license change that could impact your life.

One group we need to thank is the Developer Division at Microsoft. First they released the .NET Reference Source Code, and second for allowing a couple of developers to have some fun and provide a utility for the community.

As always let us know on CodePlex if you encounter any bugs or have feature requests.

Points of Interest

Things i have learn during the course of the implementation are as following:

a) Decomposition and parsing of a pdb file. Actually I ported a pdb parser to C# for this reason.

b) Decomposition and parsing of a pe file, finding the required debug information sections in it.

c) A srcsrv file parser , which also parses srcsrv macros included in the srcsrv files.

d) A customer WebClient class, which helps with EULA downloads.

Project Structure

The solution consist of 2 projects : DownloadLibrary and NetMassDownloader Console Application.

When we break down each component of the DownloadLibrary Class Library, they are the following:

  1. DownloadLibrary.PEParsing.PEFile The class which is responsible for PE Header and Debug Directory Parsing and detection, also responsible for PDB Download and URL Creation. Uses the IMAGE_DOS_HEADER, PESectionHeader, CV_INFO_PDB70, _IMAGE_DEBUG_DIRECTORY, IMAGE_DATA_DIRECTORY, IMAGE_FILE_HEADER, IMAGE_NT_HEADERS32, IMAGE_NT_HEADER64, IMAGE_OPTIONAL_HEADER32, IMAGE_OPTIONAL_HEADER64 Structures. Age, Guid, Version of the target PDB File is found out using this structures.

  2. DownloadLibrary.Classes.PdbParser The class is responsible for PDB Parsing. It is actually part of a different project also written by me. PdbParser For C#, which will be released in a few weeks. It supports parsing and stream decomposition of a PDB70 Version PDB File. It extracts whole streams, parses the PDB Header etc. This is required to parse out the SRCSRV file , which holds the url locations of each source code file.

  3. DownloadLibrary.Classes.PdbExtractor This class is responsible for creating SrvSrcFile from the provided PdbFile, also responsible for downloading each source file from the Microsoft Reference Server and putting them in correct directories. It uses the PDBWebclient, PdbParser, ScrSrvFile classes for that purpose.

  4. DownloadLibrary.Classes.SrcSrvDownloadableFile,SrcSrvFile These classes are responsible for SrcSrv files parsing , target URL generation and target path generation.

  5. DownloadLibrary.Classes.Eula.PDBWebclient This is a class which is derived from System.Net.WebClient which is responsible for downloading the contents from Microsoft Reference Server, Handling and Storing Of EULA Response And Eula Detection.

History

v1.3 This version has the following features:

  • Allow to process DLL or EXE files in sub-folders recursively (in addition to the top directory).
  • Allow to cleanup temporary compressed *.pd_ files.
  • Allow to download retail symbols for native DLL or EXE files from the Microsoft Symbol Server (msdl.microsoft.com) (by setting UseReferenceSourceServer to "false" in NetMassDownloader.exe.config).
  • Make the URLs of the symbol servers configurable in NetMassDownloader.exe.config.
  • Allow to specify whether to download only symbols without source code via the setting DownloadSourceCode ("true" by default) in NetMassDownloader.exe.config.
  • Use the original date-time of files from the server if available.
  • Download is now asynchronous; the download progress can be seen for each file (symbol or source code).
  • Improve the console output. It is less verbose and now easy to read.
  • Allow to resume download remaining source code files for an existing symbol file (by setting SkipExistingSourceFiles to "true" (default value) in NetMassDownloader.exe.config).

v1.2 -Proxy configuration switch added, which allows you to provide credentials for some proxies.

v1.1 a bug fix release has been released which solves a bug with some proxies not returning the correct headers.

License

This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0


Written By
Software Developer (Senior)
Turkey Turkey
.Net Developer From Istanbul Turkey.
You can reach my blog at http://www.kodyaz.com/blogs/unknown_tales_from_kerem/default.aspx

Comments and Discussions

 
GeneralRe: Community Contest Pin
tonyt21-Dec-08 13:29
tonyt21-Dec-08 13:29 
GeneralRe: Community Contest Pin
Izzet Kerem Kusmezer21-Dec-08 21:06
Izzet Kerem Kusmezer21-Dec-08 21:06 
GeneralRe: Community Contest Pin
tonyt22-Dec-08 5:30
tonyt22-Dec-08 5:30 
GeneralRe: Community Contest Pin
Izzet Kerem Kusmezer22-Dec-08 22:35
Izzet Kerem Kusmezer22-Dec-08 22:35 
GeneralRe: Community Contest Pin
tonyt23-Dec-08 17:08
tonyt23-Dec-08 17:08 
General(404) Not Found Pin
Antonio Stradivari5-Jul-08 8:09
Antonio Stradivari5-Jul-08 8:09 
GeneralRe: (404) Not Found Pin
Izzet Kerem Kusmezer6-Jul-08 21:47
Izzet Kerem Kusmezer6-Jul-08 21:47 
GeneralRe: (404) Not Found Pin
Antonio Stradivari8-Jul-08 2:08
Antonio Stradivari8-Jul-08 2:08 
GeneralRe: (404) Not Found Pin
Izzet Kerem Kusmezer11-Jul-08 0:18
Izzet Kerem Kusmezer11-Jul-08 0:18 
GeneralRe: (404) Not Found Pin
Antonio Stradivari11-Jul-08 12:34
Antonio Stradivari11-Jul-08 12:34 
GeneralRe: (404) Not Found Pin
Izzet Kerem Kusmezer14-Jul-08 4:33
Izzet Kerem Kusmezer14-Jul-08 4:33 
GeneralRe: (404) Not Found Pin
Antonio Stradivari27-Jul-08 10:33
Antonio Stradivari27-Jul-08 10:33 
GeneralBehind a NAT server [modified] Pin
Young Duke17-Jun-08 10:07
Young Duke17-Jun-08 10:07 
GeneralRe: Behind a NAT server Pin
Izzet Kerem Kusmezer17-Jun-08 20:55
Izzet Kerem Kusmezer17-Jun-08 20:55 
GeneralVS 2008 plug-in and 3.5 source Pin
Lutosław14-Jun-08 21:50
Lutosław14-Jun-08 21:50 
GeneralRe: VS 2008 plug-in and 3.5 source Pin
Izzet Kerem Kusmezer17-Jun-08 20:52
Izzet Kerem Kusmezer17-Jun-08 20:52 
QuestionCompact Framework? Pin
Malcolm Hall10-Jun-08 11:18
Malcolm Hall10-Jun-08 11:18 
AnswerRe: Compact Framework? Pin
Izzet Kerem Kusmezer10-Jun-08 20:33
Izzet Kerem Kusmezer10-Jun-08 20:33 
GeneralVS 2005 not working Pin
jack6821-Apr-08 8:22
jack6821-Apr-08 8:22 
GeneralRe: VS 2005 not working Pin
jack6821-Apr-08 8:40
jack6821-Apr-08 8:40 
GeneralRe: VS 2005 not working Pin
jack6821-Apr-08 9:18
jack6821-Apr-08 9:18 
GeneralRe: VS 2005 not working Pin
AlGol_UA20-May-08 5:26
AlGol_UA20-May-08 5:26 
GeneralThanks Pin
Jeff Circeo9-Apr-08 6:56
Jeff Circeo9-Apr-08 6:56 
JokeLong title Pin
Not Active31-Mar-08 9:26
mentorNot Active31-Mar-08 9:26 
GeneralRe: Long title Pin
Izzet Kerem Kusmezer2-Apr-08 4:40
Izzet Kerem Kusmezer2-Apr-08 4:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.