Can not publish since moving to VS 2019

蓝咒 提交于 2020-02-20 03:42:48

问题


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


回答1:


If you trust the server, then you can simply ignore the warning/error but 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 />
… 
… 



回答2:


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

<UseMSDeployExe>True</UseMSDeployExe>
<AllowUntrustedCertificate>True</AllowUntrustedCertificate>


来源:https://stackoverflow.com/questions/56311166/can-not-publish-since-moving-to-vs-2019

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!