dotnet run build and execute
Context: dotnet run builds and executes the project. It is convenient for development but not for production (use dotnet publish).
dotnet run builds the project and immediately executes the resulting application.
Basic Usage
Section titled “Basic Usage”# Build and run the current projectdotnet run
# Run with command-line argumentsdotnet run -- Hello World
# Run with specific configurationdotnet run -c ReleaseHow It Works
Section titled “How It Works”- Restores NuGet packages (if needed)
- Builds the project
- Executes the output assembly
Important Notes
Section titled “Important Notes”- Not for production: Use
dotnet publishfor deployment - First run slower: Due to package restore and compilation
- Watch mode:
dotnet watch runfor auto-reload
# Run with watch mode (auto-rebuild on changes)dotnet watch run
# Run a specific projectdotnet run --project ./MyApp/MyApp.csproj