CopySourceAsHtml for Visual Studio 2008

I ported the CopySourceAsHtml to work with Visual Studio 2008. There are some workarounds to get the existing addin to work with Visual Studio 2008 but they all assume you have 2005 installed, which I don’t. I recompiled from source, built against .NET 3.0, removed some crufty code thanks to FxCop and removed a call into olepro32.dll that wasn’t needed. I’ll provide the updated source if anyone cares, this is just a quick posting as I’m flying out the door :)

To Install

  1. Download the CopySourceAsHtml AddIn zip.
  2. Unzip to My DocumentsVisual Studio 2008Addins, if the Addins folder doesn’t exist just create it.
  3. Restart Visual Studio (you did close it first right?)
  4. Right-click some selected code and you’ll have a new Copy As HTML… menu item, that’s the gold, click it.
  5. Check the boxes in the dialog that comes up to your delight and then paste into your blog software or forum post.
  6. IMPORTANT: This Addin generates HTML code, so remember to switch into the HTML view in your blog software or forum edit box.
  7. Bob’s yer uncle

Sample

This is how a chuck of code looks when pasted (you’ll notice it uses your exact color and font settings):

[Test]
public void Select_ColumnList_Specified()
{
   SqlQuery qry = new Select("productid", "productname").From(Northwind.Product.Schema);
   ANSISqlGenerator gen = new ANSISqlGenerator(qry);
 
   string selectList = gen.GenerateCommandLine();
 
   Assert.IsTrue(selectList == "SELECT [dbo].[Products].[ProductID], [dbo].[Products].[ProductName]rn");
}

The Source

UPDATE: I’ve finally zipped up the source and uploaded it by request. Remember, I’m not the original author so all the good credit goes to someone else, I’m just the monkey that made it work on Visual Studio 2008. Here it is for your enjoyment:

CopySourceAsHtml-2.1.0-Source.zip