yyfh

使用Azure DevOps Project设置ASP.NET项目

file

我们需要先在Azure面板中创建一个Azure WebApp服务,此处步骤我将省略,然后点击部署中心如下图所示:

file

此处我选择的是Azure Repos,当然大家也可以选择GithubLocal GitFTP

file
我们需要提前在Azure DevOps中提前创建好应用程序,我这边已经提前创建好了名称为Blog
.
file

创建完后我们会在Azure DevOps Pipeline中看到默认为我们生成的管道信息,他是一个构建刚才那个应用程序并发布的过程。这个过程还是挺方便的,省去了我们一些的配置直接将这些给我们配置好,当然CD其实也配置好了,最终这个应用程序会发布到我们在在这之前创建的Azure WebApp中。

file

file

通过如下该图我们可以看到已经可以访问通了,虽然
为错误页面其实也没关系的,是因为我数据库一些信息未进行配置,现在呢我们已经将应用程序部署到Azure WebApp中了。当然CI和CD规则我们也可以将其进行修改的。

file

我们来看看管道的默认配置,默认的构建过程如下图所示。

file

下面代码片段是azure-pipelines.yml文件的相关配置如下所示

# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

jobs:
- job: ASPNETCore
  pool:
    vmImage: \'ubuntu-latest\'
  steps:
  # - task: UseDotNet@2
  #   inputs:
  #     packageType: \'sdk\'
  #     version: \'3.1.x\'

  - task: DotNetCoreCLI@2
    displayName: Build
    inputs:
      command: build
      projects: \'**/*.sln\'
      arguments: \'--configuration Release -p:Version=10.5.$(Build.BuildId)-official\'

  - task: DotNetCoreCLI@2
    displayName: Test
    inputs:
      command: test
      projects: \'**/*Tests/*.csproj\'
      arguments: \'--configuration Release\'

  - task: DotNetCoreCLI@2
    inputs:
      command: publish
      publishWebProjects: True
      arguments: \'--configuration Release -p:Version=10.5.$(Build.BuildId)-official --output $(Build.ArtifactStagingDirectory)\'
      zipAfterPublish: True

  - task: PublishBuildArtifacts@1
    inputs:
      pathtoPublish: \'$(Build.ArtifactStagingDirectory)\' 
      artifactName: \'Drop\'

当然在上面步骤中的DotNetCoreCLI@2任务会发布并并打包应用程序,我们可以在下图所示页面中进行下载发布后的应用程序。

file

分类:

技术点:

相关文章:

  • 2021-03-27
  • 2022-12-23
  • 2021-10-26
  • 2019-12-26
  • 2021-05-26
  • 2022-01-07
猜你喜欢
  • 2021-08-11
  • 2021-09-27
  • 2021-04-05
  • 2021-12-11
  • 2021-06-05
  • 2020-10-22
相关资源
相似解决方案