Create GUID in Visual Studio 2005

From time to time you need to create a GUID (Global Unique IDentifier) in order to mark your dlls. Looking in my Visual Studio 2005 I saw that this command wasn’t available in any tools menu, nor in the Customize toolbars one as a shortcut to a command.

After a quick digging on MSDN site I found this. It is written in Microsoft style – a lot of information, but no solution. It just mentioned something like ”hey, we have something that you want, but guess what – we don’t have it any more”:

  1. On the Tools menu, click Create GUID. The Create GUID tool appears with a GUID in the Result box.

Look, no GUID generation command!

So I started creating  my own Create GUID command.

Happily, the Microsoft team provided the tool in the <visual studio install>\Common7\Tools\ directory. Usually, the <visual studio install> dir is C:\Program Files\Microsoft Visual Studio 8.

Actually, there are 2 tools for creation of GUIDs:

  • GUI interface: <visual studio install>\Common7\Tools\guidgen.exe
  • Console line tool: <visual studio install>\Common7\Tools\uuidgen.exe

At first look, uuidgen seemed the winner. Running uuidgen in command line revealed the needed parameters:

GUID in command prompt.


I proceeded to setup the Create GUID command. From Visual Studio 2005 menu > Tools > External tools you can add and setup a new command to an external tool. The setup window is straight forward for experts, but new guys can be impressed by it.

Adding GUID as ExternalTools

Clicking on Add button will create a new element in the list, called [New tool 1]. This name will be overridden by whatever you write in the Title text box. Next, the command text box will be filled with exact path to the tool. Clicking the ellipsis button, you’ll be sent straight to Tools dir, where you can easily find the tool required. As arguments I put the ‘c’ value which means that the output will be upper case UUID (as you can see in the previous image).

And when clicking OK, the corresponding name, as in my case Create GUID appears in the Tools menu, just above the External Tools menu.

But surprise, when I clicked the menu button, the command prompt flashed and nothing happened.

After a brief investigation, I figured out that the tool worked, but it’s output was retained in the command prompt window. This closes immediately after the tool runes successfully, outputting the GUID.

What to do ? I switched to the next tool, Guidgen. This was simply accomplished by changing the command to the corresponding tool name and removing the argument.

 Guid generation


So after clicking on Visual Studio 2005 menu > Tools > Create GUID I got this window, in which I checked, as you can see, Registry format and then click on Copy button. Then clicking on Exit you dismiss the tool. By pasting the Clipboard content into a class, you will get this :



 Good luck with the implementation!