Sean's Blog

My Development Blog

  Home  |   Contact  |   Syndication    |   Login
  16 Posts | 0 Stories | 93 Comments | 0 Trackbacks

News

Twitter












Archives

.NET Development

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.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted on Sunday, December 06, 2009 10:36 AM

Feedback

# re: Integrating CopySourceAsHtml with Visual Studio 2010 12/6/2009 12:10 PM Yoann .B
Hi, good news.

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

Thanks.

# re: Integrating CopySourceAsHtml with Visual Studio 2010 12/6/2009 2:49 PM Sean
Funny you should mention that. I just submitted a patch:

http://copysourceashtml.codeplex.com/SourceControl/PatchList.aspx

# re: Integrating CopySourceAsHtml with Visual Studio 2010 12/11/2009 9:28 AM liveon21046
Interesting article.

Thanks,

liveon21046

# re: Integrating CopySourceAsHtml with Visual Studio 2010 8/5/2010 1:40 AM Jon Benson
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.


# re: Integrating CopySourceAsHtml with Visual Studio 2010 3/31/2011 6:41 AM Stéphane
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

# re: Integrating CopySourceAsHtml with Visual Studio 2010 2/2/2012 2:53 PM joe
the following provides this support natively

Microsoft Productivity Power Tools - Visual Studio Gallery
http://j.mp/AsODzP

# re: Integrating CopySourceAsHtml with Visual Studio 2010 2/2/2012 2:54 PM joe
Microsoft Productivity Power Tools - Visual Studio Gallery
http://j.mp/AsODzP

# re: Integrating CopySourceAsHtml with Visual Studio 2010 2/2/2012 2:57 PM Sean
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.

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