in

Dot Net Mafia

Group site for developer blogs dealing with (usually) .NET, SharePoint, Office 365, Mobile Development, and other Microsoft products, as well as some discussion of general programming related concepts.

This Blog

Syndication

Archives

Corey Roth [MVP]

A SharePoint MVP bringing you the latest time saving tips for SharePoint 2013, Office 365 / SharePoint Online and Visual Studio 2013.

Copy Source as Html in Visual Studio 2010

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.

Comments

 

Prasanna said:

Great tip, thanks for sharing.

November 21, 2009 10:29 AM
 

Mark Seemann said:

Worked like a charm - thanks so much!

February 3, 2010 11:45 AM
 

Fabian's Mix said:

The second problem of Visitors

May 9, 2010 12:29 PM
 

David Worsham said:

Thanks.  Didn't think to edit the file.

May 21, 2010 3:52 PM
 

Copy source as Html in Visual Studio 2010 « Philippsen's Blog said:

Pingback from  Copy source as Html in Visual Studio 2010 &laquo; Philippsen&#039;s Blog

October 25, 2010 9:28 AM
 

Ryan said:

You saved me a lot of time.  Thanks!

March 4, 2011 4:27 PM
 

Dave Black said:

Cool!  Thanks for reminding me about this!  I've seen this behavior in other add-ins in the past and fixed it for them - just forgot how to do it though...

April 12, 2011 1:57 PM
 

Srini said:

Excellent idea . Helped me a lot.

July 5, 2011 3:21 AM

Leave a Comment

(required)  
(optional)
(required)  
Add

About CoreyRoth

Corey Roth is an independent SharePoint consultant specializing in ECM, Apps, and Search.
2015 dotnetmafia.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems