I'm working with MSBuild (Framework version v4.0.30319 - 32 bit one) on Windows 2008 x64. Wanted to understand how MSBuild manages inline tasks. Will it compile once per call to the task ? Or will it compile once and re-use for each call to the task ?
I ran MSBuild with the "/m" argument and tried introducing a deliberate error into the C# code. And MSBuild pointed me to 1 text file (under a temp folder somewhere in my profile folder). No other text file was generated. However, I didn't know how to figure this if there were no errors.
My intent behind trying to figure this out: To know if this will be efficient to the same order as using a compiled dll (instead of an inline task). The miniscule overhead of compiling inline task code is acceptable if the compile happens just once (because I will save on SCM aspects of the code and the binaries).
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="default" ToolsVersion="4.0">
<Target Name="default">
<ItemGroup>
<A Include="1;2;3;4;5;6;7;8;9;10"/>
</ItemGroup>
<MSBuild Projects="$(MSBuildProjectFullPath)"
BuildInParallel="true"
Targets="Echoer"
ToolsVersion="4.0"
StopOnFirstFailure="true"
Properties="Prop=%(A.Identity)"/>
</Target>
<Target Name="Echoer">
<MyTask WhatToEcho="$(Prop)"/>
</Target>
<UsingTask TaskName="MyTask" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<WhatToEcho ParameterType="System.String" Required="True"/>
</ParameterGroup>
<Task>
<Code Language="cs" Type="Fragment">
<![CDATA[
Log.LogMessage("Property received: "+WhatToEcho);
]]>
</Code>
</Task>
</UsingTask>
</Project>