A simple tool to deploy and manage .NET web applications as systemd services on Linux.
-
Clone the repository:
git clone https://github.com/ilGianfri/deploy-dotnet-website.git cd deploy-dotnet-websiteNote: If you copy the files manually instead of cloning, you may need to run
sed -i 's/\r//' *.shfirst to fix Windows line endings. -
Make the scripts executable:
chmod +x install.sh dotnet-deploy.sh update.sh uninstall.sh
-
Run the installer:
sudo ./install.sh
After installation, you can use the tool from anywhere:
deploy-dotnet <published-app-folder-or-zip> <ip> <port> <main-dll> <service-name> [deployment-path]published-app-folder-or-zip: Path to your .NET publish folder or a zip file containing the published appip: IP address to listen on (e.g., 0.0.0.0 for all interfaces)port: Port number to listen on (e.g., 5000)main-dll: Name of the main DLL file (e.g., MyApp.dll)service-name: Name for the systemd service (e.g., dotnet-myapp)deployment-path: (Optional) Custom deployment path (default: /var/www/service-name)
Deploy from a publish folder:
deploy-dotnet ~/MyApp/publish 0.0.0.0 5000 MyApp.dll dotnet-myappDeploy from a zip file:
deploy-dotnet ~/MyApp.zip 0.0.0.0 5000 MyApp.dll dotnet-myappDeploy to a custom path:
deploy-dotnet ~/MyApp/publish 0.0.0.0 5000 MyApp.dll dotnet-myapp /opt/myappTo update an already-deployed application, only the service name and new files are needed. The existing configuration (port, paths, etc.) is read automatically from the service file:
update-dotnet <published-app-folder-or-zip> <service-name>Examples:
update-dotnet ~/MyApp/publish dotnet-myapp
update-dotnet ~/MyApp.zip dotnet-myappThe update script will:
- Stop the running service
- Back up the current deployment to
<deploy-path>.bak - Copy the new files
- Restart the service
- Automatically roll back to the backup if the service fails to start
- ✅ Supports both folder and zip file deployments
- ✅ Automatically creates systemd service
- ✅ Configures automatic restart on failure
- ✅ Sets up proper permissions
- ✅ Provides helpful management commands
- ✅ Color-coded output for easy reading
- ✅ Update existing deployments with automatic rollback on failure
After deployment, you can manage your service with:
# Check status
sudo systemctl status <service-name>
# View logs
sudo journalctl -u <service-name> -f
# Stop service
sudo systemctl stop <service-name>
# Start service
sudo systemctl start <service-name>
# Restart service
sudo systemctl restart <service-name>To remove the tool:
sudo rm /usr/local/bin/deploy-dotnet /usr/local/bin/update-dotnetOr, if you still have the original repository folder:
sudo ./uninstall.sh- Linux system with systemd
- .NET Runtime installed
- sudo privileges
unzipcommand (for zip file support)