Created
March 20, 2010 12:32
-
-
Save esfand/338646 to your computer and use it in GitHub Desktop.
MSBuild Inline Task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<!-- Sample Demonstrates Inline Tasks © 2010 Sayed Ibrahim Hashimi --> | |
<Project ToolsVersion="4.0" | |
DefaultTargets="Demo" | |
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<UsingTask | |
TaskName="CreateGuid02" | |
TaskFactory="CodeTaskFactory" | |
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" > | |
<ParameterGroup> | |
<NumToCreate ParameterType="System.Int32" Required="true" /> | |
<Guids ParameterType="System.String[]" Output="true" /> | |
</ParameterGroup> | |
<Task> | |
<Code Type="Fragment" Language="cs"> | |
<![CDATA[ | |
List<string> guids = new List<string>(); | |
for (int i = 0; i < NumToCreate; i++) { | |
guids.Add(Guid.NewGuid().ToString()); | |
} | |
Guids = guids.ToArray(); | |
]]> | |
</Code> | |
</Task> | |
</UsingTask> | |
<Target Name="Demo"> | |
<CreateGuid02 NumToCreate="1"> | |
<Output ItemName="Id01" TaskParameter="Guids" /> | |
</CreateGuid02> | |
<Message Text="Id01: @(Id01)" Importance="high" /> | |
<CreateGuid02 NumToCreate="4"> | |
<Output ItemName="Id02" TaskParameter="Guids" /> | |
</CreateGuid02> | |
<Message Text=" " Importance="high" /> | |
<Message Text="Id02: @(Id02)" Importance="high" /> | |
</Target> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment