<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <!-- This inline task executes c# code. --> <!-- C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe MSBuildBypass.csproj --> <!-- Feel free to use a more aggressive class for testing. --> <Target Name="Hello"> <FragmentExample /> <ClassExample /> </Target> <UsingTask TaskName="FragmentExample" TaskFactory="CodeTaskFactory" AssemblyFile="C:\Windows\Microsoft.Net\Framework\v4.0.30319\Microsoft.Build.Tasks.v4.0.dll" > <ParameterGroup/> <Task> <Using Namespace="System" /> <Code Type="Fragment" Language="cs"> <![CDATA[ Console.WriteLine("Hello From a Code Fragment"); ]]> </Code> </Task> </UsingTask> <UsingTask TaskName="ClassExample" TaskFactory="CodeTaskFactory" AssemblyFile="C:\Windows\Microsoft.Net\Framework\v4.0.30319\Microsoft.Build.Tasks.v4.0.dll" > <Task> <!-- <Reference Include="System.IO" /> Example Include --> <Code Type="Class" Language="cs"> <![CDATA[ using System; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; public class ClassExample : Task, ITask { public override bool Execute() { Console.WriteLine("Hello From a Class."); return true; } } ]]> </Code> </Task> </UsingTask> </Project>