Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not publish since moving to VS 2019

I have recently uninstalled VS 2017 and installed VS 2019.

When I publish my website via Web Deploy, if fails with 2 error messages

Failed to load publish certificate dialog due to error of Object reference not set to an instance of an object. MyWebsite.Ui

Web deployment task failed. (Connected to the remote computer ("example.com") using the specified process ("Web Management Service"), but could not verify the server’s certificate. If you trust the server, connect again and allow untrusted certificates. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_CERTIFICATE_VALIDATION_FAILED.)

I'm totally clueless on how I can solve this...

Edit

As per the comments, there is a question which is the same, but that question is about Azure. I'm not connecting to anything Azure related. I'm not saying that this makes my questions unique, more that I don't have the knowledge to understand if the cause/solution is the same. Deploying to Azure from Visual Studio fails when connecting

like image 521
MyDaftQuestions Avatar asked May 26 '19 06:05

MyDaftQuestions


2 Answers

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

  1. Open the publish profile file (.pubxml) inside /Properties/PublishProfiles in a text editor
  2. Inside the PropertyGroup element, set AllowUntrustedCertificate to True (AllowUntrustedCertificate> True /AllowUntrustedCertificate>) or add it if it doesn't exist
  3. 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 />
… 
… 
like image 99
MyDaftQuestions Avatar answered Sep 24 '22 02:09

MyDaftQuestions


In your /Properties/PublishProfiles/xxxxxx.Settings.pubxml file, add the following two lines

<UseMSDeployExe>True</UseMSDeployExe>
<AllowUntrustedCertificate>True</AllowUntrustedCertificate>
like image 30
John Rah Avatar answered Sep 24 '22 02:09

John Rah