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:
2 Comments
Hi,
Do you mind If I add this to my open source project at http://www.codeplex.com/sedodream?
Sayed Ibrahim Hashimi
You could use MSBuild community tasks Script task to call the System.Guid.NewGuid() and return the string into a property
Example from the documentation:
One Trackback
[...] Holliday on CreateGuid MSBuild Task, TFS Deployer Patches and Windows Explorer TFS Client with [...]