如何从Visual Studio 2019部署Blazor服务器托管的应用程序 [英] How can I deploy a Blazor server-hosted application from Visual Studio 2019

查看:337
本文介绍了如何从Visual Studio 2019部署Blazor服务器托管的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VS2019 Preview. 我使用最新的Blazor扩展(16.0.19227)创建了一个服务器托管"的Blazor应用程序.这是包含3个独立项目的变体...

I am using VS2019 Preview. I have created a "server-hosted" Blazor application using the latest Blazor extension (16.0.19227). This is the variant that contains 3 separate projects...

  • MyApp.Client
  • MyApp.Server
  • MyApp.Shared

我可以通过使MyApp. Server 成为活动项目来调试它,并且一切正常,但是我正努力将其发布/部署到Azure.我尝试了以下方法...

I can debug this by making MyApp.Server the active project and all works fine but I'm struggling to publish/deploy this to Azure. I have tried the following...

  • 在解决方案资源管理器中右键单击MyApp.Server
  • 选择发布"
  • 通过向导创建一个新的发布配置文件
  • 将部署模式更改为自包含"
  • 点击发布

这时在部署过程中出现错误...

At this point I get an error during deployment...

CSC(0,0):错误CS0006:元数据文件'D:\ work \ Applications \ Web \ MyApp.Client \ bin \ Release \ netstandard2.0 \ win-x86 \ MyApp.Client.dll' 找不到

CSC(0,0): Error CS0006: Metadata file 'D:\work\Applications\Web\MyApp.Client\bin\Release\netstandard2.0\win-x86\MyApp.Client.dll' could not be found

这似乎是因为Web部署配置文件中的目标运行时" 设置为 win-x86 .客户端应用程序实际上是通过以下方式构建的:

This appears to be because the "Target Runtime" in the web-deploy profile is set to win-x86. The client application is actually being built as

"D:\ work \ Applications \ Web \ MyApp.Client \ bin \ Release \ netstandard2.0 \ MyApp.Client.dll"

"D:\work\Applications\Web\MyApp.Client\bin\Release\netstandard2.0\MyApp.Client.dll"

(没有附加的win-x86子文件夹),因此部署过程似乎对构建过程所使用的路径做出了错误的假设.在发布对话框中无法指定空白/无关目标运行时.

(without the additional win-x86 subfolder) so the deployment process seems to be making an incorrect assumption about the paths used by the build process. There's no way in the publish dialog to specify a blank/don't care target runtime.

这是否有解决方法,或者我使用了错误的部署方法?

Is there a workaround for this or perhaps I am using the wrong approach for deployment?

有些

There is some official documentation but it's not very helpful.

更新似乎部署使用的是Client项目的输出路径,然后仅将 netstandard2.0 {Target Runtime} 附加到其上,以便更改输出路径客户项目中的问题不足以解决此问题.

Update It seems that the deployment is using the output path of the Client project and then just appending netstandard2.0{Target Runtime} to it so changing the output path in the Client project is not enough to work around the issue.

更新2 通过编辑xml删除发布配置文件中的 RuntimeIdentifier 标记只会导致部署时错误,指出空的RuntimeIdentifier与自包含的不兼容.部署.不幸的是,自包含的部署是必需的,因为Azure尚未直接托管.net core 3.

Update 2 Removing the RuntimeIdentifier tag in the publish profile by editing the xml simply results in deploy-time error stating that an empty RuntimeIdentifier is incompatible with a self-contained deployment. Unfortunately the self-contained deployment is necessary because Azure does not yet host .net core 3 directly.

推荐答案

因为Azure尚未直接托管.net core 3.

because Azure does not yet host .net core 3 directly.

但是确实如此.

在Azure门户中,部署后转到您的WebApp(或预先创建一个).

In the Azure Portal, go to your WebApp after deployment (or create one beforehand).

转到扩展,然后单击添加[ + ]并选择ASP.NET Core 3(免费托管为x86).

Go to Extensions and click Add [+] and select ASP.NET Core 3 (x86 for the free hosting).

也可以转到设置",常规"并启用WebSocket,默认情况下它们处于关闭状态.

Also go to Settings, General and enable WebSockets, they're Off by default.

请注意,Preview-6不能作为扩展使用,因此请使用Preview-5或以自包含的方式进行部署.

Note that Preview-6 is not available as an extension, so either use Preview-5 or deploy as self-contained.

这篇关于如何从Visual Studio 2019部署Blazor服务器托管的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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