black electronics

.NET Compile in VS Code

Steps to compile C# files into a .NET executable from Visual Studio Code.

Some offensive tooling and PoCs ship as raw C# source rather than a compiled binary. Here’s the quickest path to compiling one from Visual Studio Code, without needing the full Visual Studio IDE.

Set up the project

Install the .NET SDK and the C# extension for VS Code (VS Code will prompt to install it automatically once you open a .cs file).

Terminal window
dotnet new console -n YourAppName # Scaffold a new console application
cd YourAppName

Drop your source into the generated project, then build and run it:

Terminal window
dotnet build --configuration Release
dotnet run --project YourAppName

Target an older .NET version

If you have the .NET 8 SDK installed but need to build against an older runtime (down to .NET 5), edit the .csproj file:

<TargetFramework>net5.0</TargetFramework> <!-- was net8.0 -->

For .NET 4.0 and below, also comment out ImplicitUsings and Nullable in the same file, then build again:

Terminal window
dotnet build --configuration Release
Useful LinksPentest PayloadsCheat Sheets