What steps are needed to load a PE file (like Mimikatz) from memory using MSBuild?

To load a PE file from memory using MSBuild, you write C# code within an Inline Task to read the PE bytes and execute them, similar to loading a .NET assembly reflectively. The XML file must specify `TaskFactory="CodeTaskFactory"` and the correct path to `Microsoft.Build.Tasks.v4.0.dll`. A crucial detail is that on 64-bit systems, you must use the 64-bit MSBuild executable at `C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe` to avoid errors. The article [Use MSBuild To Do More](/news/use-msbuild-to-do-more) provides a working example and points to related research on [Loading PE files into memory via .NET](/news/loading-pe-files-into-memory-via-net).

Related article:

Use MSBuild To Do More