Introduction
This guide provides a comprehensive, step-by-step tutorial for deploying a .NET Core or Blazor application to an IIS website using a Plesk Publishing XML file in Visual Studio 2022. It also includes instructions for handling SSL errors that may arise during the publishing process within Visual Studio.
Prerequisites
- Visual Studio 2022 installed.
- Plesk Control Panel access with a hosting plan that includes IIS.
- Plesk Web Deploy Publishing XML file (located in your Plesk Control Panel Dashboard).
- .NET Core or Blazor application ready for deployment.
- Administrator credentials for Plesk.
Step-by-Step Guide
1. Prepare Your .NET Core or Blazor Application
Ensure your application runs correctly on your local machine. Thoroughly test the application before deploying it to ensure all functionality works as expected.
2. Obtain the Plesk Publishing XML File
- Log in to your Plesk account.
- Navigate to Websites & Domains.
- Select the domain you wish to deploy to.
- Click on Web Deploy Publishing Settings.
- Download the Plesk Publishing XML file. This file contains the deployment configuration settings needed for publishing.
3. Set Up the Publishing Profile in Visual Studio
- Open your project in Visual Studio 2022.
- In the Solution Explorer, right-click your project and select Publish.
- In the Publish window, choose Import Profile.
- Locate and import the Plesk Publishing XML file.
4. Configure Publish Settings
After importing the profile, configure the publish settings:
- Configuration: Choose Release for production deployment.
- Target Framework: Select the appropriate .NET version.
- Deployment Mode: Select Self-Contained if the required .NET runtime is not installed on the server; otherwise, select Framework-Dependent.
5. Addressing SSL Errors in Visual Studio
Some users encounter SSL errors when using Visual Studio 2022 for publishing, typically due to self-signed certificates or certificates not trusted by the local machine. Follow these steps to bypass SSL errors:
-
Disable SSL Verification Temporarily:
- Open the Publish Profile:
- Navigate to the
Properties\PublishProfiles
folder in your project. - Open the
.pubxml
file related to your profile in a text editor.
- Navigate to the
- Edit the Publish Profile:
- Add the following XML element inside the
<PropertyGroup>
tag:<AllowUntrustedCertificate>true</AllowUntrustedCertificate>
- Add the following XML element inside the
- Save and close the file. This setting allows Visual Studio to bypass SSL certificate errors temporarily during publishing.
- Open the Publish Profile:
-
Trust the SSL Certificate:
- If your server uses a self-signed certificate, download the certificate file.
- Open the certificate file and click Install Certificate.
- Choose to install the certificate to the Trusted Root Certification Authorities store.
6. Publish Your Application
- In Visual Studio, go to the Publish tab.
- Click Publish to start the deployment process. Visual Studio will compile your application and deploy it to the selected IIS site.
7. Verify Deployment
After the deployment completes:
- Visit your website's URL in a browser.
- Verify that your application is running correctly and that all features are functioning as expected.
8. Troubleshooting Common Issues
-
Application Doesn't Start:
- Check the site logs for detailed error logs.
- Verify all necessary dependencies are installed on the server.
-
SSL Warnings:
- Ensure the correct SSL certificate is installed and trusted.
-
500 Internal Server Error:
- Review your
web.config
file and ensure it matches the server environment setup.
- Review your
9. Best Practices
- Back-Up Regularly: Always back up your website and databases before deploying new changes.
Conclusion
Publishing a .NET Core or Blazor application to a Windows 2019/2022 IIS website using a Plesk Web Deploy Publishing XML file in Visual Studio 2022 is straightforward when following these steps. Properly handling SSL errors and ensuring all settings are correct will result in a smooth deployment process.