Created
September 14, 2012 19:16
-
-
Save centur/3724080 to your computer and use it in GitHub Desktop.
Sample Msbuild Inline task
This file contains 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"?> | |
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> | |
<UsingTask TaskName="SomeFibbonaci" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> | |
<ParameterGroup> | |
<FibbonaciSeqLength Required="True" ParameterType="System.Int32"/> | |
<Result ParameterType="Microsoft.Build.Framework.ITaskItem[]" Output="True"/> | |
</ParameterGroup> | |
<Task> | |
<Reference Include="Microsoft.Build"/> | |
<Reference Include="Microsoft.Build.Framework"/> | |
<Reference Include="Microsoft.Build.Utilities.v4.0"/> | |
<Using Namespace="Microsoft.Build.Evaluation"/> | |
<Using Namespace="Microsoft.Build.Execution"/> | |
<Using Namespace="Microsoft.Build.Utilities"/> | |
<Using Namespace="Microsoft.Build.Framework"/> | |
<Code Type="Fragment" Language="cs"> | |
<![CDATA[ | |
var fibboList = new List<ITaskItem>(FibbonaciSeqLength-1); | |
double prev = -1; | |
double result = 1; | |
double sum; | |
int i; | |
for(i = 0;i <= FibbonaciSeqLength-1;++i) | |
{ | |
sum = result + prev; | |
prev = result; | |
result = sum; | |
string itemIdentity = result.ToString(); | |
var metadata = new Dictionary<string, string>{{"prevNumber",i!=0?prev.ToString():"no ;)"}}; | |
fibboList.Add(new TaskItem(itemIdentity, metadata)); | |
} | |
Result = fibboList.ToArray(); | |
]]> | |
</Code> | |
</Task> | |
</UsingTask> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment