Geeks With Blogs
Sean's Blog My Development Blog

For copying and pasting source from Visual Studio into my blog posts, I have found CopySourceAsHtml to be very helpful. For those that are not familiar with it, CopySourceAsHtml integrates nicely with Visual Studio by adding a context menu item, which allows you to easily copy source code from your source files. All of the HTML formatting is handled by the add in.

As far as I’m aware, there is currently no official release of CopySourceAsHtml for Visual Studio 2010. The good news, however, is that I was able to modify the associated .Addin file to make it work. This is not an official “workaround” from the CopySourceAsHtml developers; I just happened to find that it worked. Thus far, I have not encountered any issues with using CopySourceAsHtml within Visual Studio 2010 (at the time of this posting, I’m using the Visual Studio 2010 beta 2 release).

To integrate CopySourceAsHtml with Visual Studio 2010, please follow the instructions, below:

  1. Locate the CopySourceAsHtml.AddIn file (by default, it’s located in, C:\Program Files\J.T. Leigh & Associates\CopySourceAsHtml)
  2. Copy and paste this file into the Addin directory for Visual Studio 2010 (locate this by selecting Tools –> Options –> Add-in/Macros Security)
  3. Edit the XML in the .Addin file, changing the text within the <Version> elements to 10.0.
  4. Change the text in the <Description> element so that it references Visual Studio 2010 rather than 2008.
  5. Restart Visual Studio 2010 if it was already open
  6. Check Tools –> Add-in Manager and verify that the CopySourceAsHtml add in is checked to enable it.

Add-in Dialog

Your updated XML should look like this:

<?xml version="1.0" encoding="utf-8" standalone="no"?>

<Extensibility xmlns="http://schemas.microsoft.com/AutomationExtensibility">

  <HostApplication>

    <Name>Microsoft Visual Studio Macros</Name>

    <Version>10.0</Version>

  </HostApplication>

  <HostApplication>

    <Name>Microsoft Visual Studio</Name>

    <Version>10.0</Version>

  </HostApplication>

  <Addin>

    <FriendlyName>CopySourceAsHtml</FriendlyName>

    <Description>Adds support to Microsoft Visual Studio 2010 for copying source code, syntax highlighting, and line numbers as HTML.</Description>

    <Assembly>JTLeigh.Tools.Development.CopySourceAsHtml, Version=3.0.3215.1, Culture=neutral, PublicKeyToken=bb2a58bdc03d2e14, processorArchitecture=MSIL</Assembly>

    <FullClassName>JTLeigh.Tools.Development.CopySourceAsHtml.Connect</FullClassName>

    <LoadBehavior>1</LoadBehavior>

    <CommandPreload>0</CommandPreload>

    <CommandLineSafe>0</CommandLineSafe>

  </Addin>

</Extensibility>

Update: For anybody that wants to help test, I have submitted this update as a patch to the CopySourceAsHtml project.

Posted on Sunday, December 6, 2009 10:36 AM | Back to top


Comments on this post: Integrating CopySourceAsHtml with Visual Studio 2010

# re: Integrating CopySourceAsHtml with Visual Studio 2010
Requesting Gravatar...
Hi, good news.

You should send a patch on CopySourceAsHtml for that VS 2010 support !

Thanks.
Left by Yoann .B on Dec 06, 2009 12:10 PM

# re: Integrating CopySourceAsHtml with Visual Studio 2010
Requesting Gravatar...
Funny you should mention that. I just submitted a patch:

http://copysourceashtml.codeplex.com/SourceControl/PatchList.aspx
Left by Sean on Dec 06, 2009 2:49 PM

# re: Integrating CopySourceAsHtml with Visual Studio 2010
Requesting Gravatar...
Interesting article.

Thanks,

liveon21046
Left by liveon21046 on Dec 11, 2009 9:28 AM

# re: Integrating CopySourceAsHtml with Visual Studio 2010
Requesting Gravatar...
I've seen this in various places and there is one issue with this. It adds quite a few seconds to your VS 2010 startup time.

I've done this myself but I move it in/out of my Addins folder when I need it.
Left by Jon Benson on Aug 05, 2010 1:40 AM

# re: Integrating CopySourceAsHtml with Visual Studio 2010
Requesting Gravatar...
I've tried it and it worked, but my VisualStudio now starts up in 30-40s. Without the addin, it takes 5s! A quick monitoring of the devenv startup showed that lots of time is spent to look for unexisting HKCU/Sofware/Microsoft/VisualStudio/10.0_Config/AutomationOptions/RunMacros registry key.
Any hint to correct that?
Thank you
Left by Stéphane on Mar 31, 2011 6:41 AM

# re: Integrating CopySourceAsHtml with Visual Studio 2010
Requesting Gravatar...
the following provides this support natively

Microsoft Productivity Power Tools - Visual Studio Gallery
http://j.mp/AsODzP
Left by joe on Feb 02, 2012 2:53 PM

# re: Integrating CopySourceAsHtml with Visual Studio 2010
Requesting Gravatar...
Microsoft Productivity Power Tools - Visual Studio Gallery
http://j.mp/AsODzP
Left by joe on Feb 02, 2012 2:54 PM

# re: Integrating CopySourceAsHtml with Visual Studio 2010
Requesting Gravatar...
Hi Joe, thank you for the link. When I wrote this blog post, the power tools weren't available. I've since started using Power Tools, as well.
Left by Sean on Feb 02, 2012 2:57 PM

Your comment:
 (will show your gravatar)


Copyright © Sean Fao | Powered by: GeeksWithBlogs.net