Can not publish since moving to VS 2019
I know this is old, but I did find a different solution that worked for me (after trying to create/upload certificates; reset publishing profiles, etc.)
If you have the nuget package MSBuild.Microsoft.VisualStudio.Web.targets installed in your project, it's old and that's what breaks it. Remove that package and your publish will work. No need to add the AllowUntrusted flat in your pubxml as long as your server IS trusted. (*ie Azure.)
If you trust the server, then you can simply ignore the warning/error by editing the publish file directly
https://stackoverflow.com/a/33662970/3252861
- Open the publish profile file (.pubxml) inside /Properties/PublishProfiles in a text editor
- Inside the PropertyGroup element, set AllowUntrustedCertificate to True (AllowUntrustedCertificate> True /AllowUntrustedCertificate>) or add it if it doesn't exist
- Set UsePowerShell to False (False).
I didn't do the 3rd point, so I guess I either have previously or didn't need it
Now we can follow the advice on https://developercommunity.visualstudio.com/content/problem/484286/publish-fails-to-iis-using-msdeploy-webdeploy.html and actually add the following 2 entries
<UseMSDeployExe>True</UseMSDeployExe>
<AllowUntrustedCertificate>True</AllowUntrustedCertificate>
It should be pointed out that some have reported you only need to use one of those two:
<AllowUntrustedCertificate>True</AllowUntrustedCertificate>
So, the start of the pubxml
XML file now looks like
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<UseMSDeployExe>True</UseMSDeployExe>
<AllowUntrustedCertificate>True</AllowUntrustedCertificate>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>True</ExcludeApp_Data>
<MSDeployServiceURL>domain</MSDeployServiceURL>
<DeployIisAppPath>name</DeployIisAppPath>
<RemoteSitePhysicalPath />
…
…
In your /Properties/PublishProfiles/xxxxxx.Settings.pubxml file, add the following two lines
<UseMSDeployExe>True</UseMSDeployExe>
<AllowUntrustedCertificate>True</AllowUntrustedCertificate>
I´m using VS 2019
Add the next lines into PropertyGroup node:
<UseMSDeployExe>True</UseMSDeployExe>
<AllowUntrustedCertificate>true</AllowUntrustedCertificate>