Creating an external operation

Top  Previous  Next

The steps to create an external operation are the following:

  • Create a Class Library project. You can use any .NET managed language such as C# or VB.NET.
  • Add references to EnvDTE and VSLangProj (the references used by all add-ins).
  • Add a reference to the MZTools assembly (you can use the Object Browser to discover the MZ-Tools object model).
  • Create a public class that inherits from the OperationBase class. The same project can contain more than one operation.
  • At minimum, override the OnInitialize and OnExecuteOperationInProjectItem methods (see the Hello World Operation). In the OnExecuteOperationInProjectItem method, perform the actual operation on the file. Depending on the kind of operation, you may want to modify the file or you may want to examine it and add output to a result window. See Adding Output to a Result Window.
  • Optionally, you can override other methods. For example, you may want to perform some action before or after a solution, project or folder is processed. See Overriding OperationBase Class Methods.
  • Optionally, you can provide user options (which are requested before each execution) through a class that inherits from the UserOptions class and a usercontrol that implements the IUserOptionsPropertyPage interface. See Providing User Options.
  • Optionally, you can provide admin options (which apply to all executions and appear in the Corporate Options window of MZ-Tools) through a class that inherits from the AdminOptionsBase class and a usercontrol that implements the IAdminOptionsPropertyPage interface. See Providing Admin Options.
  • Compile the assembly DLL and copy it to any of these folders:
     
    - The folder of MZ-Tools DLL (admin rights are required), typically:
     
    "C:\Program Files\MZTools6"
     
    - The folder which stores the options files (admin rights are not required), typically:
     
    Windows 7 / Windows Vista: "C:\Users\<username>\AppData\Roaming\MZTools Software\MZTools6"
    Windows XP / Windows 2000: "C:\Documents and Settings\<username>\Application Data\MZTools Software\MZTools6"
     
    The next time that MZ-Tools is loaded, it will add commands for the operations in the assembly and it will add the proper menu entries under the Other Utilities menu of MZ-Tools.
     
    To unplug the external operation(s) from MZ-Tools, just remove the assembly DLL from that folder. The next time that MZ-Tools is loaded, it will remove the commands and menus for the operations of the missing assembly.