Publish like exe
How to Create and Run an EXE from ASP.NET Core
You can create a standalone .exe file from your ASP.NET Core project that a client can run directly — without installing .NET — by publishing it as a self-contained executable.
✅ Step-by-Step Instructions
- Open your command prompt or terminal.
- Navigate to your ASP.NET Core project folder.
- Run the following command to publish a self-contained EXE:
dotnet publish -c Release -r win-x64 --self-contained true -o ./publish
-c Release
: Uses the release build configuration.-r win-x64
: Targets 64-bit Windows (you can change this for Linux or macOS).--self-contained true
: Bundles the .NET runtime into the EXE.-o ./publish
: Outputs the build to thepublish
folder.
๐ After Publishing
Navigate to the publish
folder. You will find an EXE file, like:
YourApp.exe
▶️ How to Run It
You can either double-click the EXE file or run it from the terminal:
cd publish
YourApp.exe
This will launch the ASP.NET Core app using the Kestrel server, typically accessible at:
http://localhost:5000
๐ Notes
- Make sure no firewall is blocking port 5000.
- This works for Web APIs or Razor Pages/Blazor Server projects.
- Optional: Include a
.bat
file to simplify launching for non-technical users.
๐ฆ Bonus: Creating a Batch Launcher
Create a file named launch.bat
in the publish
folder:
@echo off
start YourApp.exe
pause
Now the client can just double-click launch.bat
to start your app!
That's it! You've created a distributable EXE version of your ASP.NET Core project.
Comments
Post a Comment