Reflector Addin: CopyPath and VS Command Prompt Here

by Jason Haley 24. January 2009 11:01

Update: Added Windows Explorer menu item to open windows explorer to the directory of the dll/exe.

I finished reading Jon Skeet's book C# in Depth: What you need to master C# 2 and 3 a few weeks ago and lately have been playing with the sample code using the Reflector.Snippy addin.  When I wrote the Reflector.Snippy addin, I added a dropdown so the temp assembly could be created as an executable (see the options dialog screen shot below on where this setting is located in the Reflector Options dialog).

image

Since I know the temp assembly can be created as an executable, I often find myself wanting to locate the temp assembly's exe to run it in order to see the output.  Normally, in my everyday life as a developer using Visual Studio, I have a couple of utilities I use in this type of situation: Copy Path and VS.Net Xxxx Command Prompt Here (see my entry from August 2007 - Utility of the Month for more information on these utilities) ... but they are shell extensions - not Reflector extensions.  So I put together a Reflector addin to provide the same sort of functionality in Reflector.

The addin actually started with just the Copy Path functionality then, while testing the Copy Path functionality, I decided the Command Prompt Here functionality would be a nice addition (hence the name of the addin's dll is CopyPathAddin.dll).

The functionality is simple:

Copy Path
When you right-click on a dll/exe's name, a submenu on the context menu with the title of "Copy Path" provides two menu items.  The first menu item is the complete path to the dll file and the second item is the complete path to the directory the dll is in.   If there are any environment variables in the paths, they are expanded.  The behavior when the user clicks on the menu item is that the chosen path is copied to the clip board.

Command Prompt Here
When you right-click on the dll's name, there is a menu item that says VS2005 Command Prompt and another for VS2008 Command Prompt.  When you click on these menu items, a command window (cmd.exe) opens with the proper environment variables set for the chosen Visual Studio (only supports 2005 and 2008 as well as x86 for both ... if the code doesn't work for your environment you'll need to get the code and tweak it).

Windows Explorer (added 1/26/2006)
When you right-click on the dll/s name, there is a menu item that says Windows Explorer.  When you click on this menu item, a new explorer.exe window is opened to the directory the dll/exe is in.

After adding the addin to your Reflector the context menu (right-click menu) for a dll/exe's name should look something like the following:

image

Now using the Reflector.Snippy addin, I can write up some sample code, compile it and then easily get a command prompt to run it without leaving Reflector.  This makes me think a nice addition to the Reflector.Snippy addin would be an execute button if it is set to compile as an executable ... I'll let you know if I make this change anytime soon :)

Downloads
Here are the links to the addin's source code and dll (both are zipped):

The source code: http://jasonhaley.com/files/CopyPathAddin.zip

The Dll only: http://jasonhaley.com/files/CopyPathAddinDllOnly.zip

Comments (2) | Post RSSRSS comment feed |

Categories:
Tags:

Comments

Comments are closed