CreateGuid MSBuild Task

April 4, 2008 at 9:25 pm | In Team Foundation Server |

There doesn’t seem to be a way to create GUIDs out-of-the-box in MSBuild or through the MSBuild community tasks, so I created a custom task to do it for you.

Usage:

<!–

This task creates a new GUID using System.Guid.NewGuid()

The Format parameter is optional. If specified it must be one of “N” “D” “B” “P” “”. Default is “D”

See http://msdn2.microsoft.com/en-us/library/s6tk2z69.aspx for more information.

N = 32 digits: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
D = 32 digits separated by hyphens: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
B = 32 digits separated by hyphens, enclosed in brackets: {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
P = 32 digits separated by hyphens, enclosed in parentheses: (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

–>

<CreateGuid Format=”D”>
    <Output TaskParameter=”Output” PropertyName=”MyGuid” />
</CreateGuid>

<Message Text=”Guid: $(MyGuid)” />

Download:

Download CreateGuid.cs.txt

2 Comments »

RSS feed for comments on this post. TrackBack URI

  1. Hi,
    Do you mind If I add this to my open source project at http://www.codeplex.com/sedodream?

    Sayed Ibrahim Hashimi

    Comment by Sayed Ibrahim Hashim — April 5, 2008 #

  2. [...] Holliday on CreateGuid MSBuild Task, TFS Deployer Patches and Windows Explorer TFS Client with [...]

    Pingback by Team System News : VSTS Links - 04/09/2008 — April 10, 2008 #

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.