Prerequisites
Ensure that the following prerequisites are met before starting the deployment process:
- .NET SDK installed on the server environment.
- Ensure Node.js and npm are installed if using any front-end JavaScript dependencies.
- A supported web server environment (e.g., IIS, Apache, Nginx).
Step 1: Build and Publish the Application
Navigate to the project directory and execute the following command to build and publish the application.
dotnet publish -c Release -o ./publish
This command compiles the application in Release mode and outputs the published files to the ./publish
directory.
Step 2: Configure the Web Server
For IIS Deployment
Install the ASP.NET Core Hosting Bundle
Download and install the ASP.NET Core Hosting Bundle on your IIS server. This bundle includes the necessary runtime and hosting libraries required to run ASP.NET Core applications.Create an Application Pool
- Open IIS Manager.
- Create a new Application Pool configured for .NET CLR Version “No Managed Code”, and set the Managed Pipeline Mode to “Integrated”.
Set Up the Site
- Right-click on “Sites” and choose “Add Website”.
- Choose an appropriate site name, set the Physical Path to the path where the published files are located (e.g.,
C:\path\to\your\project\publish
), and configure the Binding settings.
Configure the Website
- Ensure that the Application Pool created earlier is selected for the site.
- Set any necessary permissions for the IIS user (e.g.,
IIS_IUSRS
) to access the published files.
For Nginx Deployment
Install Nginx
Ensure Nginx is installed on your server.Server Block Configuration
Create a new Nginx server block configuration. Open the configuration file (typically found in/etc/nginx/sites-available/default
or in a new file under/etc/nginx/sites-available/yourapp
):
server {
listen 80;
server_name yourdomain.com; # Replace with your actual domain
location / {
proxy_pass http://localhost:5000; # Assuming the app runs on port 5000
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
- Start and Enable Nginx
Restart Nginx to apply the new configuration.
sudo systemctl restart nginx
sudo systemctl enable nginx
Step 3: Configure the Application Settings
Modify the appsettings.json
file in the published files to suit your production environment. This includes adjusting settings related to databases, logging, and any other necessary configuration parameters.
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning"
}
},
"ConnectionStrings": {
"DefaultConnection": "Server=yourserver;Database=yourdb;User Id=youruser;Password=yourpass;"
}
}
Step 4: Running the Application
For Kestrel Web Server
If using Kestrel directly, run the application from the published output:
cd path/to/your/project/publish
dotnet PacmanBlazor.dll
For IIS
Start the site in IIS Manager. Verify the site is running under the created Application Pool.
For Nginx
If using Nginx as a reverse proxy, ensure the Kestrel application is up and running on the specified port. Utilize a process manager (like systemd
, pm2
, or similar) for managing the Kestrel process.
Step 5: Verify the Deployment
Open a web browser and navigate to your domain (e.g., http://yourdomain.com
). Confirm that the application loads and performs as expected. Review logs to troubleshoot any issues that arise during startup.
Conclusion
Successful deployment of the stevedunn/pacmanblazor
project in a production environment requires correct configuration of the web server and application settings. Ensure to regularly monitor logs and application performance to maintain desired service levels.
Source: Information derived from project guidelines and known deployment practices in similar ASP.NET contexts.