4

I'm finding the Azure devops documentation pretty poor - or maybe I'm just not familiar enough with it for it to make any kind of sense to me. Having said that, I've managed to create a build pipeline that runs tests and published my project, then I created a release pipeline and have successfully released to an Azure App Service.

However, I honestly don't know what is happening behind the scenes...

I have this build pipeline yaml:

# 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

pool:
  vmImage: 'Ubuntu-16.04'

variables:
  buildConfiguration: 'Release'

steps:
- script: dotnet restore
  displayName: Restoring Dependencies

- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'dotnet build $(buildConfiguration)'

- task: DotNetCoreCLI@2
  displayName: Unit Tests
  inputs:
    command: test
    projects: '**/*Tests/*.csproj'
    arguments: '--configuration $(buildConfiguration)'

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

- task: PublishBuildArtifacts@1

I'm not sure if I need both the DotNetCoreCLI@2 and PublishBuildArtifacts@1 publishing tasks. Are they doing the same thing? Where are the files being published to? Can I see them?

And I've created a Release Pipeline where artifacts points at the above release pipeline:

#Your build pipeline references an undefined variable named ‘Parameters.ConnectedServiceName’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references an undefined variable named ‘Parameters.WebAppKind’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references an undefined variable named ‘Parameters.WebAppName’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972

steps:
- task: AzureRmWebAppDeployment@4
  displayName: 'Deploy Azure App Service'
  inputs:
    azureSubscription: '$(Parameters.ConnectedServiceName)'
    appType: '$(Parameters.WebAppKind)'
    WebAppName: '$(Parameters.WebAppName)'

How is the release pipeline moving the files to the Azure App Service, and can I look to see what is going to the App Service?

Bit of a noob with devops as you might have guessed

Pierre.Vriens
  • 7,225
  • 14
  • 39
  • 84
Percy
  • 141
  • 2

2 Answers2

1

Lets take this line by line:

My additions are added as comments.

trigger:
- master
# The branch you are building.

pool:
  vmImage: 'Ubuntu-16.04'
# The type of VM your code will run on.

variables:
  buildConfiguration: 'Release'
#This ends up defining which webconfig file to use.

steps:
- script: dotnet restore
  displayName: Restoring Dependencies

- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'dotnet build $(buildConfiguration)'
# Builds your application
- task: DotNetCoreCLI@2
  displayName: Unit Tests
  inputs:
    command: test
    projects: '**/*Tests/*.csproj'
    arguments: '--configuration $(buildConfiguration)'
#Runs unit tests for your application
- task: DotNetCoreCLI@2
  displayName: Publishing
  inputs:
    command: publish
    publishWebProjects: True
    arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
    zipAfterPublish: True
#Pushes your application as an artifact (You'll be able to see it in your list of artifacts in Azure DevOps)
- task: PublishBuildArtifacts@1

As for your release script, you are forgetting to pass in the values so your release script isn't doing anything at the moment. But when it does work, it will take the objects from your artifacts or container images and deploy them into your webapp the same way it would do it if you ran those commands from your local machine.

avi
  • 1,279
  • 1
  • 13
  • 32
0

First to answer the difference between DotNetCoreCLI@2 Publish and PublishBuildArtifacts@1

In DotNetCoreCLI@2 Publish task you are only publishing your build output\ files built by your code to $(Build.ArtifactStagingDirectory) which is a predefined variable for the build artifact location. This need not even be $(Build.ArtifactStagingDirectory). Here you are just telling the build pipeline where to place the files built from your code.

In PublishBuildArtifacts@1 task, it lets you publish your $(Build.ArtifactStagingDirectory) or your built binaries (if generated elsewhere) or even your source code to a file share or Azure pipelines. Basically PublishBuildArtifacts@1 is also what defines the content or artifact that gets passed to your release pipleline from your build pipeline.

Hope this answers the question.If not the below documentation from microsoft should.

https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#publish

Publish Build Artifacts

Jerry
  • 21
  • 3