Elton Stoneman

  Home  |   Contact  |   Syndication    |   Login
  120 Posts | 0 Stories | 3601 Comments | 0 Trackbacks

News

Archives

Post Categories

[Source: http://geekswithblogs.net/EltonStoneman]

There are a couple of reasons why you might want PDB files available in the GAC, say if you're running coverage reports over unit tests as part of your CI build, and the assemblies being instrumented all live in the GAC, or if you want to deploy BizTalk PDB files as a troubleshooting aid. Patrick Cauldwell has a PowerShell script to install PDBs to the GAC, which is a good basis for an MSBuild task to do the same.

The principle is straightforward – find the "hidden" GAC directory where it the assembly is deployed and copy the PDB file there. Danger here is that the GAC structure may change, so the task uses AssemblyName.CodeBase which gives you the full path to the physical location, rather than determining it from the current format.

The main work is done here:

string pdbFilename = string.Format("{0}.pdb", Path.GetFileNameWithoutExtension(this.AssemblyPath));

string pdbPath = Path.Combine(Path.GetDirectoryName(this.AssemblyPath), pdbFilename);

//if source PDB is found:

if (File.Exists(pdbPath))

{

//get the strong name info from the assembly:

AssemblyName gacAssemblyName = Assembly.LoadFile(this.AssemblyPath).GetName();

string gacPath = this.GetGacPhysicalLocation(gacAssemblyName);

//if GAC location found:

if (!string.IsNullOrEmpty(gacPath))

{

//copy PDB file:

try

{

File.Copy(pdbPath, Path.Combine(gacPath, pdbFilename));

Log.LogMessage("Added PDB file to GAC: {0}, location: {1}", pdbFilename, gacPath);

}

//log other conditions...

Where AssemblyPath is the path to the un-GACd assembly where the PDB file is expected to be found (e.g. the build output directory):

<Target Name="DeployPdbToGac">

<DeployPdbToGac AssemblyPath="$(BuildOutputDir)\x.y.dll"/>

</Target>

 

Full source code is here: MSBuild Task to Deploy PDB Files to GAC

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted on Wednesday, September 17, 2008 9:55 PM

Feedback

# re: Installing PDB files to the GAC with MSBuild 5/29/2009 5:34 PM Manuel Babuglia
Great task! I was looking for something like this.

I have found a little bug though: You are never setting success = true after successfully copying to the GAC, so the build always fail.


I have another issue, property $(BuildOutputDir) doesn't seem to be defined. The task works for me if I specify the full output path, but I would like to use a property as you are doing. Is there another property that should have the full path?

Thank you very much,
Manuel



# re: Installing PDB files to the GAC with MSBuild 4/24/2010 7:28 AM sozo
That's a pretty cool article.The information you have given are really very useful thanks a lot for sharing.Keep blogging.

# re: Installing PDB files to the GAC with MSBuild 4/26/2010 4:19 AM content filter256
Very nice and useful post, thanks.This post is not helpful for newbies also for experts, because it is true everyone is not aware of everything.

# re: Installing PDB files to the GAC with MSBuild 5/3/2010 9:24 AM security camera-59
Having written articles that require this much work, I commend you for your service to the future bloggers. I’m sure they will appreciate it.Keep it up.

# re: Installing PDB files to the GAC with MSBuild 7/8/2010 5:35 AM Matts Doomsday 2012
Too hard and technical for me to understand... Peace!

Catholic Saints Names List, Patron Saints

# re: Installing PDB files to the GAC with MSBuild 8/7/2010 7:29 AM application blocking491
Great post! Thanks for informative listing. Its really helpful for the beginners.Keep blogging.

# re: Installing PDB files to the GAC with MSBuild 9/14/2010 4:52 PM flag rental
This has been helpful. A quick note to say "thanks." Alexander

# re: Installing PDB files to the GAC with MSBuild 10/9/2010 8:45 AM get motivated seminars
I have read few of articles here and can say it was really interesting, thanks for sharing this.Hope will post again soon.

# re: Installing PDB files to the GAC with MSBuild 11/11/2010 5:11 AM Uffizi tickets reservation
Thanks a lot for the valuable post about Installing PDB files to the GAC with MSBuild..But it is too hard to understand for me as i am new to this language.

# re: Installing PDB files to the GAC with MSBuild 1/28/2011 6:11 AM leg vein pain
This is a great task to Installing PDB files to the GAC with MSBuild! I was looking for something like this, as a new learner it’s too hard and technical for me to understand. But this post explains it in such way that is so east to understand for a reader.

# re: Installing PDB files to the GAC with MSBuild 1/28/2011 6:48 AM colocation utah
This has been fruitful for me. I have been working with this type of project. I have gained a lot of newthings from this post. Thanks a lot for sharing such a valuable post with us.

# re: Installing PDB files to the GAC with MSBuild 3/23/2011 9:49 AM submission article
MSBuild allows you compile C# from the command line..just like NANT. The MSBuild file consists of a Project tag containing Targets, PropertyGroups, and ItemGroups.

# re: Installing PDB files to the GAC with MSBuild 5/13/2011 6:54 AM online computer science degree
I want to use PDB files to deploy BizTalk PDB files as a troubleshooting aid. This more appropriate for my business.

# re: Installing PDB files to the GAC with MSBuild 6/17/2011 3:51 AM driving lessons Birmingham
This post is well written…thanks for the post!Some great information to be absorbed in this post. Thanks!Keep up the good work.I am interested very much in the subject matter of your blog, it’s my first visit.


# re: Installing PDB files to the GAC with MSBuild 9/7/2011 9:19 AM cheap link building
Thanks for providing the instruction on how to install PDB files to the GAC with MSBuild.

# re: Installing PDB files to the GAC with MSBuild 9/18/2011 5:03 PM Driving lessons Bristol
Thanks this post helped massively

# re: Installing PDB files to the GAC with MSBuild 12/22/2011 5:25 AM Music Lyrics
Nice script! It is working well!

# re: Installing PDB files to the GAC with MSBuild 12/23/2011 11:46 PM buy water dispenser
I think youve made some really interesting points. Not too many people would basically think about this the way you just did. Im really impressed that theres so significantly about this subject thats been uncovered and you did it so nicely, with so significantly class. Good 1 you, man! Truly terrific stuff right here. bottleless water cooler for offices

# re: Installing PDB files to the GAC with MSBuild 12/27/2011 7:07 AM flor
It's really a very good article,I learn so much thing from it,thanks.You are really a nice person real estate toronto

# re: Installing PDB files to the GAC with MSBuild 12/28/2011 8:34 PM lance
I would be very thankful if you continue with quality what you are serving right now with your blog...I really enjoyed it...and i really appreciate to you for this. online english | teaching job in shanghai

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: