Introduction
Some years ago, I missed some useful commands and tools in Visual Studio, so I started developing macros and add-ins for this development environment. This project started with some special web reports, and grew up to a collection of useful tools that help in developing and controlling my work and files. The result was an add-in for Visual Studio 2003 that adds commands for comparing files and folders, an explore command, and some useful reports for web projects.
Now, this version is a port to Visual Studio 2010 (may also run with VS 2005 and VS 2008), of the original project that is still available at CodeProject.
There you can find a lot of the implementation details still valid for this version. The main difference between Visual Studio 2003 and the newer versions is the registration and setup of new Add-ins that is significantly easier by using a *.addin file that describes all installation parameters.
After installing, there are new commands available in the command window as well as in the context menu of the Solution Explorer. Most of them use a new Tool window to output the results of the commands and to offer new functionalities in the context of the reported items.
If you are interested in detailed descriptions, see the original article. Here, I want to give some hints that were useful while porting the original project, that might help you to port yours.
The Diff Code
I've got several requests from users who were searching for a diff algorithm. So, the C# code that is used to compare two files can now also be found as a separate CodeProject project: An O(ND) Difference Algorithm for C#.
Manual Setup
This is the biggest change for building add-ins with Visual Studio 2005 and beyond: there is no more need for COM registrations and registry hacks!
All you need to start using this add-in is to extract all the files from the WebReports8_setup.zip archive to the folder "C:\Documents and Settings\[your name]\My Documents\Visual Studio 2010\AddIns". You might have to create this folder first if it doesn't exist yet.
When Visual Studio starts, it searches this path and will find the WebReports8.AddIn that holds all the additional information.
For older versions of Visual Studio, there are appropriate folders available.
There are also other folders that can be used. You can see all the folders that are scanned in the Tools.Options dialog in the add-in section.
Changed Libraries
Visual Studio .NET 2003 shared some libraries for handling the menu part with the Office products. This is no longer true, and the import of Microsoft.Office.Core
is obsolete.
Now, you have to use the namespaces EnvDTE80
and Microsoft.VisualStudio.CommandBars
. The EnvDTE90
and EnvDTE100
namespace was not necessary for building the Add-in, so you can remove it from the included namespaces if you build a new Add-in on your own.
There are some minor differences between the old and the new libraries, but the overall functionality is the same. There is still some casting of the COM types necessary.
Most of the code changes are in the Connect.cs class that handles the registration, and is called by the Visual Studio 2005 events.
Developing the Addin File
Don't get confused (I got) with the 2 *.addin files that are generated by the wizard. Only the one that is located in the Visual Studio 2010\Addins
folder is relevant and it's the one that is linked from the project but is not stored in the project folder. Here you can edit all the stuff that needs to be set up. I recommend to delete the one in the project while developing and saving a copy to the project folder, when everything runs fine.
Resources
Resources can now be built into managed satellite DLLs. You will not need a C compiler any more to create an empty DLL that will hold the resources.
There are some good articles on that topic, and of course, MSDN helps a lot: Creating Managed Satellite DLLs.
I have added the batch file buildRes.bat to the sources that help calling the resgen and other tools.
resgen.exe Icons.resx
al.exe /t:lib /embed:icons.resources
/culture:en-US /out:Webreports8.resources.dll
md bin\en-us
copy WebReports8.resources.dll bin\en-us
rem -- cleanup --
del WebReports8.resources.dll
The resx files can be edited by VS.NET.
I actually created two DLLs because they are language specific and I wanted to support English and German.
The project also contains a postBuild script that copies all the files that are used at runtime to the addins folder. If you compile the project by yourself, you should check this script and change the path to the addins folder to your specific installation and username.
Helpful Links
History
- 2010.05.09 - Version 2.2 - Version for Visual Studio 2010
- 2006.05.27 - Version 1.1 - German resources added
- 2006.03.21 - Version 1.0 - Some fixes (as suggested by Carlos Quintero)
- 2006.01.31 - Version 0.9 - Just a port to the new Visual Studio environment