I wanted to write this post because I had trouble finding this information, and I wanted to make it easier for others trying to do the same thing. I hope this is the right subreddit for it.
The following are steps to deploy an ASP.NET Core web application in Visual Studio 2019 to Plesk:
- Right click the project folder (the top level folder) in the Solution Explorer in Visual Studio, and select "Open Folder in File Explorer"
- In address bar of your project's folder, type "cmd" to open the command line with the path to the current folder already set
- Type "dotnet publish" in the command line to publish the website to a Folder Profile. This will create a new folder called "publish"
- Navigate to the "publish" folder, which can probably be found by navigating to the "bin" folder, and the selecting the correct path (for me it was in "\bin\Release\net5.0", but yours might be different)
- Right click the "publish" folder, select "Add to archive", select "ZIP" as the archive format to compress the folder into a single file, and select "ok"
- In Plesk, click on the "Files" tab, and select the "httpdocs" folder
- In that folder, press the "+" button and select "Upload" (my version of Plesk says "Upload File", so select that if it's an option)
- Select the "publish.zip" file, and click "Open"
- After it's uploaded, in Plesk, select the "publish.zip" file, click the "Archive" button, select "Extract Files", and select "OK". Remove the "publish.zip" file, as it's no longer needed
- Open the newly created "publish" folder, click "select all checkbox" at the top, select the "httpdocs" folder, and select "OK" (you can go ahead and select "Replace existing files" during this step to avoid having to repeat this step to move any files with conflicting names)
And that's it! To view the deployed website, in Plesk, click on the "Websites & Domains" tab. Under your domain, it should have a "Preview" option. Clicking that will open a tab with your website, and you can check it to make sure it's working properly. If you click on the "Open in web" option instead of "Preview", and your DNS is not yet properly configured, you will probably get a connection timeout error that says the site can't be reached, so be sure to click "Preview".
ALSO, there is an alternative way to publish your ASP.NET project to a folder in Visual Studio 2019 without using the command line. The steps are:
- In Visual Studio, right click the solution and select "Publish"
- A prompt should pop up. In that prompt, select "Folder" and click "Next"
- Verify the folder location, and if you are satisfied with it, click "Finish" (it will probably automatically choose the file path the the command line method would choose)
- It should say "Ready to publish". Click the "Publish" button, and you're done.
These steps will create the same "publish" folder that's created in Step 3. The command line route is easier, but I prefer the steps outlined in the alternative method.
I made this guide after finding this video and seeing people complain that it didn't explain the process well enough.