Steve Cook, a long time architect on my team, has made available a sample that shows how to access the UML meta data in Visual Studio’s  new UML project system and export that data into the OMG’s XMI data format. XMI is the OMG standard used to describe UML meta data for exchange between various tool vendors.

In Visual Studio 2010 Ultimate, we have the ability to import XMI ( via the Visualization and Modeling Feature Pack ), but we didn’t get XMI export into the feature pack.

If you are interested in this sample, here are the steps you need to do to take it for a test drive:


  1. Download the sample
    Once downloaded, double check to see if you need to unblock the zip file. Better to do this now if needed, rather than all the extracted files. Just right click on the file and select “Properties”:
    SNAGHTML19cfffc9If you don’t see the “Unblock” button, then you can safely skip this step.
  2. Extract the zip file to your favorite directory and double-click on the XmiExporterSample.sln file.
    This will launch VS for you. If you are presented with any dialogs about version control, you can safely ignore. If you are asked, choose to permanently remove the version control settings from the solution.
  3. Right click on the XmiExport project in the Solution Explorer and select “Set as StartUp Project”
    Also, if you are running a x64 bit version of windows, you will need to go into the project settings to point at the appropriate version of Visual Studio. Right click on the XmiExport project, select Properties, click on the Debug tab, and make sure you are pointing at the correct DevEnv.exe. On my machine, that happens to be here : “C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe”
  4. Set the “Solution Configuration” to be Release
  5. Rebuild your solution
  6. Double click the Microsoft.Example.XmiExporter.vsix file
    In the output directory for the XmiExporter project ( XMIExporter\bin\Release ), you’ll find a Microsoft.Example.XmiExporter.vsix file. Double clicking that vsix will install the XmiExport sample into your Visual Studio instance.
  7. Restart Visual Studio, create a new UML modeling project, create a UML class diagram, and notice the new “Export XMI…” menu item when right-clicking in the background of the diagram!
    Drop some elements on the diagram so you have something to export.
  8. Select “Export XMI…”
    A dialog will popup asking where you want the resulting XMI file to go.


And that’s it!

The great thing about providing this as a sample is you can jump into the source to see how to get access at all the UML meta data in your UML Modeling projects. To start, reopen the XmiExporterSample and open the XmiExportCommand.cs file. Set a break in the Execute method…

Hope that helps,