Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deploy .NET Website Tool

A simple tool to deploy and manage .NET web applications as systemd services on Linux.

Installation

  1. Clone the repository:

    git clone https://github.com/ilGianfri/deploy-dotnet-website.git
    cd deploy-dotnet-website

    Note: If you copy the files manually instead of cloning, you may need to run sed -i 's/\r//' *.sh first to fix Windows line endings.

  2. Make the scripts executable:

    chmod +x install.sh dotnet-deploy.sh update.sh uninstall.sh
  3. Run the installer:

    sudo ./install.sh

Usage

After installation, you can use the tool from anywhere:

deploy-dotnet <published-app-folder-or-zip> <ip> <port> <main-dll> <service-name> [deployment-path]

Parameters

  • published-app-folder-or-zip: Path to your .NET publish folder or a zip file containing the published app
  • ip: 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)

Examples

Deploy from a publish folder:

deploy-dotnet ~/MyApp/publish 0.0.0.0 5000 MyApp.dll dotnet-myapp

Deploy from a zip file:

deploy-dotnet ~/MyApp.zip 0.0.0.0 5000 MyApp.dll dotnet-myapp

Deploy to a custom path:

deploy-dotnet ~/MyApp/publish 0.0.0.0 5000 MyApp.dll dotnet-myapp /opt/myapp

Updating an Existing Deployment

To 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-myapp

The 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

Features

  • ✅ 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

Management Commands

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>

Uninstall

To remove the tool:

sudo rm /usr/local/bin/deploy-dotnet /usr/local/bin/update-dotnet

Or, if you still have the original repository folder:

sudo ./uninstall.sh

Requirements

  • Linux system with systemd
  • .NET Runtime installed
  • sudo privileges
  • unzip command (for zip file support)

About

Script to publish a dotnet website on a Linux machine

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages