Create & inserting GUIDs in Visual Studio

If you’re using WIX and you’re adding components to the product file by hand then you’ve probably found yourself creating and cutting/pasting a lot of GUIDs which can be a real pain and productivity killer. There is the “Create GUID” menu option under tools but that still requires calling and then cutting / pasting. The other day one of the other members on our team came up with these steps to create a macro that will create and insert a new GUID and can be bound to a keyboard short cut.

  1. Go to Tools – Macros – Macro Explorer and paste the following into a module:
[code language=”vb”] Sub InsertGuid() Dim objTextSelection As TextSelection objTextSelection = CType(DTE.ActiveDocument.Selection(), EnvDTE.TextSelection) objTextSelection.Text = System.Guid.NewGuid.ToString(“D”).ToUpperInvariant End Sub [code]
  1. Then assign it a keyboard shortcut through Tools – Environment/Keyboard, you can generate a GUID in-place with a simple keyboard shortcut.

No more copy/paste

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *