Visual Studio Publish / Web Deploy

Web deploy can be used to upload a site developed through Visual Studio to the web server.  Using web deploy can help avoid issues like missing assemblies that might occur when uploading a Visual Studio project via FTP.  Note that the steps below are for Visual Studio 2019.  Additional information relating to Deployment Mode in Core can be found at the bottom of the article.
 
 
Set up a publish profile
 
In Visual Studio, right click the project and select Publish from the menu.
 
 
 
 
Select Web Server (IIS) as the publish target then Next.
 
 
 
 
Select Web Deploy as the Specific Target then Next.




The web deploy connection settings required are
 
Server:  w##.winhost.com (replace "w##" with the Server Name from the Site Info pane; see below)
Site name:  the website's domain name / deploy path (if deploying to a subdirectory, it is added to the site name; ie, domain.com/subdirectory)
User name:  the FTP username
Password:  the FTP password
Destination URL:  optional and can be left blank; for visiting the site after successful deployment
 
If there is a database, click Next to set up the connection string.  If not, click Finish.
 
 
 
 
Site Info
 
The connection settings for Web Deploy can be reviewed at Winhost Control Panel > Sites > the applicable domain name > Site Info pane.  You can also click on the Publishing Information link to download a profile which you can use to import into Visual Studio.  This will create 2 profiles, one for FTP and one for Web Deploy.  On Visual Studio 2022, it will create a 3rd profile (blank) which you can ignore.  You can select either one and enter your password to deploy. 
 
 
 
 
Connection String
 
If a connection string is required for the deployed project, a Winhost database connection string can be found at Winhost Control Panel > Sites > the applicable domain name > MS SQL Manager > Manage (applicable database).  Note that the example Connection String does not contain the database password in plain text, so it will need to be updated after copying it to Visual Studio.  After adding the connection string, Save.
 
 
 
 
ACL

The default setACL behavior in Visual Studio will alter permissions on a Winhost site unless disabled in the publish profile.  After setting up the publish profile, but before actually publishing, right click on the project and select Open Folder in File Explorer.




The profile.pubxml file will be found in ..\appName\My Project\PublishProfiles or ..\appName\Properties\PublishProfiles (example below).  Drag and drop the file into Visual Studio to edit it.




Once open, add the following line to the PropertyGroup to disable the behavior.

<IncludeSetACLProviderOnDestination>False</IncludeSetACLProviderOnDestination>
And save the file.



Publish
 
After saving the publish profile, return to the publish pane and click Publish to deploy the project to the web server.  If there is an error on publish, open a ticket with the Support Department and provide the error in case Web Management Service needs to be manually restarted.
 
 
 
 
ACL and Trust Level Errors

If setACL was not set to false before deploying, you may see general permission errors or, more specifically, the below error.




In cases of permissions errors, open a ticket with the Support Department and permissions can be reset on the site.

Easily confused with permissions issues is the trust level setting of an app.  Returning similar general app errors or the exception below.




To adjust the trust level of the app open the project's web.config and add

<trust level="Full"/>
to the system.web element, save, and redeploy the updated web.config.




Core Publish Settings

Deployment Mode for Core applications depends on the version being deployed.  To check if Framework-Dependent deployment is available for the selected version see https://support.winhost.com/kb/a1498/installed-_net-core-frameworks.aspx.   Self-Contained deployment should be used for any newer version until installed.

Target Runtime can be left Portable or set to win-x86.
 
 


Core Hosting Model defaults to InProcess for deployed apps.  If attempting to run more than one app from a single app pool, all Core apps will need to be changed to OutofProcess (case insensitive).  The hosting model can be changed by updating the .csproj file (left click on the Project name in Visual Studio) and add the following to the PropertyGroup:

<AspNetCoreHostingModel>OutofProcess</AspNetCoreHostingModel>