Skip to content
Pinter Computing

Knowledge Base for IT Professionals, Teachers, and Astronauts

Pinter Computing

Knowledge Base for IT Professionals, Teachers, and Astronauts

  • Home
  • Programming
  • DevOps
  • Project Management
  • Software and Hardware
  • Miscellaneous
  • Egyebek
  • About
  • Experience
  • Education
  • Contact
  • Home
  • Programming
  • DevOps
  • Project Management
  • Software and Hardware
  • Miscellaneous
  • Egyebek
  • About
  • Experience
  • Education
  • Contact
Close

Search

Knowledge Base

Build a standalone Windows executable in Visual Studio

By Laszlo Pinter
April 7, 2025 3 Min Read
0

Standalone Windows executables are compiled ahead of time (AOT) and distributed as three executable files (.exe, .dll, .runtimeconfig.json). This format is ideal for small executables called from the command line or from other applications.

To create an AOT Windows executable in Visual Studio 2022 or later

Start a new project

  • Create a C# console app

  • Name the app

  • Select .NET 8.0 or later framework, and Enable native AOT publish

  • To test the application we will write some temporary code in Program.cs
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Test executable started");

// Read the command line arguments into an array
string[] arguments = args;
Console.WriteLine($"Number of command line arguments {arguments.Length}");

if (arguments != null && arguments.Length > 0)
{
    var firstArgument = arguments[0];
    Console.WriteLine($"First argument = {firstArgument}");

    if (firstArgument == "ERROR" )
    {
        Console.WriteLine("Throw divide by zero exception");
        int a = 0;
        int b = 1 / a;
    }

}

Console.WriteLine("Test executable exited without error");  

Build the executable

Prerequisites

To be able to build, link and publish the standalone executable we need to install the “Desktop development with C++” Visual Studio workload.

  • In the Tools menu select Get Tools and Features

  • Install the Desktop development with C++ workload

Publish the executable

  • In the Solution Explorer right-click the project and select Publish

  • Select Folder as the target

  • Select Folder again for the specific target

  • Select the target location and click Finish

  • Close the dialog when the build has been completed

Running the standalone executable

By default the output is placed in the bin\Debug\net8.0 directory

To run the (not really) “standalone” application, we need the following three files in the same directory:

  • .exe
  • .dll
  • .runtimeconfig.json

Setup project

To access the .msi file

  • Build the Setup project
  • The file is saved at Setup/[PROJECT_CONFIGURATION]/Setup.msi

See Visual Studio Installer Projects Extension and .NET on creating a Setup project

Troubleshooting

See RuntimeIdentifier is required for native compilation. Try running dotnet publish with the -r option value specified. in case you get this error during publishing.

Author

Laszlo Pinter

Follow Me
Other Articles
Previous

Developing a secure .NET 8 (core) console application

Next

Data is Null. This method or property cannot be called on Null values.

No Comment! Be the first one.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Last Changes

  • Argument of type '(number | null)[]' is not assignable to parameter of type '(err: Error, result: QueryResult) => void' June 20, 2026
  • Cities: Skylines II Developer Mode June 20, 2026
  • How to stop the rain and snow in Cities: Skylines II June 20, 2026
  • 'CSII_MANAGEDPATH' has incorrect path(s) when building Cities: Skylines II mod June 20, 2026
  • Decompiling the Cities: Skylines II code June 20, 2026

Tags

.NET .NETcore 3Dprinting ASP.NET Core AutodeskInventor AWS C# Chef cloud DevOps Docker EntityFramework Games Git Go iOS iPad iPhone iPod Java Kubernetes Linux MacOSX MSSQL MVC Node.js Packer PowerShell Python RDS RightScale Ruby security Splunk TeamCity Terraform TestKitchen Tomcat Ubuntu Vagrant VirtualBox VisualStudio Windows WordPress Xcode

Recent Comments

  • Zengei László on MyHeritage családfa exportálása és küldése emailben
  • Raúl Castillo on DynDns update error
  • MICHAEL on Windows Media Player 12 cannot find the album information
  • Nargis on Configure Epson ET-3850 scanning on Windows 11
  • Venczelné Zemen Erika on Delta S2302 termosztát programozása

–

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Copyright 2026 — Pinter Computing. All rights reserved.