Copy Source as Html in Visual Studio 2010
Posted
Friday, November 20, 2009 1:33 PM
by
CoreyRoth
I was working on my first SharePoint 2010 post today since I actually installed some bits and quickly discovered that I did not have Copy Source As Html working with Visual Studio 2010 Beta 2. If you’re a blogger like me, you will find that you are quite addicted to this useful tool as it makes pasting good looking code segments quite easy. Unfortunately, they haven’t released an installer that works with Visual Studio 2010 yet, so I decided to see if I could figure out how to get it to work. Now, I’m not expert on Visual Studio Addins, so it took me some experimenting. I installed the product as normal, but when I opened Visual Studio, I did not find the addin loaded. After some investigating, I decided to copy the CopySourceAsHtml.AddIn file into my user folder. Specifically this goes in C:\Users\<UserName>\My Documents\Visual Studio 2010\Addins. Note: the My Documents folder is actually the Documents folder if you are looking at it directly on the file system. Also to note is that the Addins folder probably will not exist so you need to create it.
After I did this, I tried opening Visual Studio again and again did not see my addin loaded. I then decided to open the file and take a look. I quickly saw something that stood out at me.
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Extensibility xmlns="http://schemas.microsoft.com/AutomationExtensibility">
<HostApplication>
<Name>Microsoft Visual Studio Macros</Name>
<Version>9.0</Version>
</HostApplication>
<HostApplication>
<Name>Microsoft Visual Studio</Name>
<Version>9.0</Version>
</HostApplication>
<Addin>
<FriendlyName>CopySourceAsHtml</FriendlyName>
<Description>Adds support to Microsoft Visual Studio 2008 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>
This is version 10 of Visual Studio so I decided to increment the new two version elements as shown below.
<?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 2008 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>
After I saved the changes, I restarted Visual Studio and sure enough the addin loaded and worked correctly. In fact I pasted the above snippets using the tool in Visual Studio 2010. If you have never used Copy Source as Html before, go check it out. It’s a handy tool for pasting code snippets.