A while back I talked about the new feature available in MSBuild 4 Inline Tasks in.
In the previous examples I have use C# as my language of choice. C# is not your only choice you can also use VB.Net but you can also use JavaScript! When MSBuild creates the class for the inline task it uses CodeDom to do so, and JavaScript is one of its supported languages. Perhaps its actually called JScript. In any case take a look at the project file below which shows this in action.
<Project ToolsVersion="4.0" DefaultTargets="PrintValues" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <UsingTask TaskName="Jsex01" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> <ParameterGroup> <Files ParameterType="Microsoft.Build.Framework.ITaskItem[]"/> </ParameterGroup> <Task> <Code Type="Fragment" Language="javascript"> <![CDATA[ function printMessageFor(item : Microsoft.Build.Framework.ITaskItem) { Log.LogMessage(item.ItemSpec + "fullpath: " + item.GetMetadata("FullPath")); } for(var i = 0; i<Files.length; i++) { printMessageFor(Files[0]); } ]]> </Code> </Task> </UsingTask> <ItemGroup> <Source Include="one.cs"/> <Source Include="two.cs"/> <Source Include="three.cs"/> <Source Include="four.cs"/> </ItemGroup> <Target Name="PrintValues"> <Jsex01 Files="@(Source)" /> </Target> </Project>
Here you can see that I created a new inline task called, Jsex01 and its written in Javascript. Then inside of the PrintValues target this task is called. If you execute the PrintValues target the result will be what you see below.
So if you prefer JavaScript to C# or VB.Net then you should try this out!
Sayed Ibrahim Hashimi
Remember Me
a@href@title, b, blockquote@cite, strike, strong, sub
Theme design by Jelle Druyts
Powered by: newtelligence dasBlog 2.3.9074.18820
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2012, Sayed Ibrahim Hashimi
E-mail