迁移到 VS 2019 后无法发布 [英] Can not publish since moving to VS 2019

查看:33
本文介绍了迁移到 VS 2019 后无法发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近卸载了 VS 2017 并安装了 VS 2019.

当我通过 Web Deploy 发布我的网站时,如果失败并显示 2 条错误消息

<块引用>

由于未将对象引用设置为对象实例的错误,无法加载发布证书对话框.我的网站.Ui

Web 部署任务失败.(使用指定的进程(Web 管理服务")连接到远程计算机(example.com"),但无法验证服务器的证书.如果您信任服务器,请再次连接并允许不受信任的证书.了解更多信息:http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_CERTIFICATE_VALIDATION_FAILED.)

我完全不知道如何解决这个问题...

编辑

根据评论,有一个相同的问题,但该问题与 Azure 相关.我没有连接到任何与 Azure 相关的东西.我并不是说这使我的问题独一无二,更多的是我不知道原因/解决方案是否相同.连接时从 Visual Studio 部署到 Azure 失败

解决方案

如果您信任服务器,那么您可以通过直接编辑发布文件来忽略警告/错误

https://stackoverflow.com/a/33662970/3252861

<块引用>

  1. 在文本编辑器中打开/Properties/PublishProfiles 中的发布配置文件 (.pubxml)
  2. 在 PropertyGroup 元素内,将 AllowUntrustedCertificate 设置为 True (AllowUntrustedCertificate> True/AllowUntrustedCertificate>) 或在它不存在时添加它
  3. 将 UsePowerShell 设置为 False (False).

我没有做第 3 点,所以我想我以前要么不需要它

现在我们可以遵循 https://developercommunity.visualstudio.com/content/problem/484286/publish-fails-to-iis-using-msdeploy-webdeploy.html 并实际添加以下2 条目

True<AllowUntrustedCertificate>True</AllowUntrustedCertificate>

应该指出的是,有些人报告说您只需要使用这两个中的一个:

True

所以,pubxml XML 文件的开头现在看起来像

<项目工具版本=4.0";xmlns=http://schemas.microsoft.com/developer/msbuild/2003"><属性组><UseMSDeployExe>True</UseMSDeployExe><AllowUntrustedCertificate>True</AllowUntrustedCertificate><WebPublishMethod>MSDeploy</WebPublishMethod><LastUsedBuildConfiguration>发布</LastUsedBuildConfiguration><LastUsedPlatform>任何 CPU</LastUsedPlatform><SiteUrlToLaunchAfterPublish/><LaunchSiteAfterPublish>True</LaunchSiteAfterPublish><ExcludeApp_Data>True</ExcludeApp_Data><MSDeployServiceURL>域</MSDeployServiceURL><DeployIisAppPath>名称</DeployIisAppPath><RemoteSitePhysicalPath/>……

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

解决方案

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 />
… 
… 

这篇关于迁移到 VS 2019 后无法发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆