4

I'm a little confused on the Azure Pipeline steps. My solutions has many projects and one UI project that contains both an ASP.Net-Core WebApi/MVC with Angular.

the Build Solution builds similar to the

steps:
- task: VSBuild@1
  displayName: 'Build solution'
  inputs:
    solution: '$(Parameters.solution)'
    msbuildArgs: '/p:DeployOnBuild=true 
      /p:WebPublishMethod=Package 
      /p:PackageAsSingleFile=true 
      /p:SkipInvalidConfigurations=true 
      /p:PackageLocation="$(build.artifactstagingdirectory)\\"'
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'

The default Publish Artifact is:

steps:
- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
  condition: succeededOrFailed()

I'd like to do something with 2 artifacts (this doesn't work):

steps:
- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: webapi'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)\\MVCProject\bin\$(BuildConfiguration)\netcorapp2.2'
    ArtifactName: webapi
  condition: succeededOrFailed()

steps:
- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: angular'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)\\MVCProject\clientapp\dist'
    ArtifactName: angular
  condition: succeededOrFailed()

What am I missing / What the right/better way to do this. (moving angular out of the project does not solve this problem, and we aren't ready for that yet)

  • Did you solve this? I've ran into a similar decision. FWIW I went the other way, that is: a single artifact with multiple packages. I ran into all sorts of issues with this as it seems to confuse the release pipeline and it's any persons' guess as to which application is deployed where... – Ste Pammenter Nov 7 '19 at 11:58
  • @StePammenter Yes I did (finally). Answer incoming. – Erik Philips Nov 20 '19 at 1:23
  • Thanks for getting back. As it turned out for me, my fault was in copying the same Azure function settings, not with the pipeline itself! – Ste Pammenter Nov 20 '19 at 10:50
4

Here is my YAML for multiple artifacts from a single build.

pool:
  name: Hosted Windows 2019 with VS2019
  demands:
  - msbuild
  - visualstudio
  - vstest
  - npm

steps:
- task: NuGetToolInstaller@0
  displayName: 'Use NuGet 4.4.1'
  inputs:
    versionSpec: 4.4.1

- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: '$(Parameters.solution)'

- task: VSBuild@1
  displayName: 'Build solution WebApi'
  inputs:
    solution: '$(Parameters.solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"'
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'
    msbuildArchitecture: x64

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: WebApi'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
    ArtifactName: 'dotnet-webapi'
  condition: succeededOrFailed()

- task: DeleteFiles@1
  displayName: 'Delete build.artifactstagingdirectory for Angular'
  inputs:
    SourceFolder: '$(build.artifactstagingdirectory)'
    Contents: '**'

- task: Npm@1
  displayName: 'npm install'
  inputs:
    workingDir: project/ClientApp
    verbose: false

- task: Npm@1
  displayName: 'npm run prod-build'
  inputs:
    command: custom
    workingDir: project/ClientApp
    verbose: false
    customCommand: 'run prod-build'

- task: Npm@1
  displayName: 'npm run dev-build'
  inputs:
    command: custom
    workingDir: project/ClientApp
    verbose: false
    customCommand: 'run prod-dev'
  enabled: false

- task: CopyFiles@2
  displayName: 'Copy Angular/Dist to build.artifactstagingdirectory'
  inputs:
    SourceFolder: project/ClientApp/dist/ClientApp
    Contents: |
     **
     !config.json
    TargetFolder: '$(build.artifactstagingdirectory)'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: Angular'
  inputs:
    ArtifactName: angular

| improve this answer | |
  • In a release pipeline, how would you specify which Build Artifact to use? – Dbloom Apr 10 at 0:19
  • 1
    @Dbloom Both artifacts are available when you select a folder/archive/package in the release pipeline task. So I just select the one I need for the correct release task. – Erik Philips Jul 8 at 22:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.