本文介绍了部署托管到Azure的Blazor WebAssembly App ASP.NET Core的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio 2019中,我有一个 3-projects解决方案结构(客户端,服务器,共享).我创建它时所做的工作完全可以描述为:

I have a 3-projects solution structure (Client,Server,Shared) in Visual Studio 2019. What I exactly did to create it can be described as:

  • [GUI] BlazorApp-> Blazor WebAssembly App-> checbox打钩了[v]托管了ASP.NET Core

等于:

  • [CMD] dotnet new blazorwasm --hosted

我想将此项目部署到Azure ,但是我遇到了一些问题:

I would like to deploy this projects to Azure, but I am facing some problems:

  1. 当我尝试使用连续GitHub部署并将其分支附加到它时,出现错误,该错误基本上表示不支持3.1版本(最高为3.0版本).很奇怪,在Azure上设置WebApp服务器时,我选择了.NET Core 3.1(LTS)选项[托管在Linux上,没有其他选项]
  2. 如果我想从VS2019中手动发布它,我应该部署哪个项目"?


我认为,这3个项目的模板只是Microsoft的友好之手,因此我不必创建2个单独的项目,而我想做的事情只需部署两个分开的 WebApp:

  1. 使用.NET Core 3.1构建的REST API(混合.Shared和.Server项目 OR 只需创建WebAPI项目)
  2. Blazor WebAssembly应用程序(所谓的客户端)
  1. REST API built with .NET Core 3.1 ( mix .Shared and .Server projectsOR just create WebAPI project)
  2. Blazor WebAssembly App (so called client-side)

尽管,如果可以一次完成所有操作-我希望这样做.

Although, if this can be done all at once - I would prefer it.

先谢谢您!

编辑1(10.03.20 10:15)

EDIT 1 (10.03.20 10:15)

这是我的* .yml文件:

This is my *.yml file:

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: DotNetCoreCLI@2
  displayName: 'dotnet publish $(buildConfiguration)'
  inputs:
    command: publish
    publishWebProjects: True
    arguments: '--configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)'
    zipAfterPublish: True

- task: PublishBuildArtifacts@1
  displayName: 'publish artifacts'

WebApp的配置:

Configuration of WebApp:

  • 发布:代码

  • Publish: Code

运行时堆栈:.NET Core 3.1(LTS)

Runtime stack: .NET Core 3.1 (LTS)

操作系统:Linux

OS: Linux

编辑2(10.03.20 10:31)

EDIT 2 (10.03.20 10:31)

收到以下错误:

错误:多个软件包与指定的模式匹配:D:\ a \ r1 \ a * *.zip.请限制搜索模式.*

Error: More than one package matched with specified pattern: D:\a\r1\a**.zip. Please restrain the search pattern.*

编辑3(10.03.20 10:15)

EDIT 3 (10.03.20 10:15)

在我从该列表更改了特定的zip文件之后,构建终于成功了(此文件夹中的所有项目都显示在屏幕截图中.我选择了WebApp.zip) 但是-我转到url,只看到您的应用程序服务已启动并正在运行"默认屏幕.

Build finally succeded, after I changed the specific zip file from this list (all the items in this folder are visible on a screenshot. I chose WebApp.zip)But - I go to the url and I am only seeing "Your app service is up and running" default screen..

推荐答案

我遇到了同样的问题,而不是直接通过Github,而是使用Azure DevOps从Github中提取,构建并部署到我的Webapp.

I ran into this same issue, instead of going through Github directly, I used Azure DevOps to pull from Github, build and then deploy to my webapp.

您会在这里找到很棒的教程.

You'll find a great tutorial here.

https://youtu.be/jRgLSMlp28U

这篇关于部署托管到Azure的Blazor WebAssembly App ASP.NET Core的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 04:10