Thursday, 19 July 2012

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 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 key board short cut.

  1. Go to Tools – Macros – Macro Explorer and paste the following into a module:
  2. Sub InsertGuid()
    Dim objTextSelection As TextSelection
    objTextSelection = CType(DTE.ActiveDocument.Selection(), EnvDTE.TextSelection)
    objTextSelection.Text = System.Guid.NewGuid.ToString("D").ToUpperInvariant
    End Sub

  3. 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

No comments:

Post a Comment