Azure CI/D Build Pipeline not building all projects

Viewed 228

I have a repo with 4 projects, 2 class libraries, 1 asp.net core project and 1 console.exe project

When I run the following, it only builds a zip for the asp.net core project. I would like it to also build a zip for the console app

trigger:
- master

pool:
  vmImage: 'windows-2019'

variables:
  buildConfiguration: 'Release'

steps:
- task: UseDotNet@2
  displayName: 'Install .NET Core SDK'
  inputs:
    version: 5.0.x
    performMultiLevelLookup: true
    includePreviewVersions: true # Required for preview versions

- task: DotNetCoreCLI@2
  displayName: "Publish"
  inputs:
    command: 'publish'
    arguments: '-r win-x64 --configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'

- task: PublishBuildArtifacts@1
  displayName: "Upload Artifacts"
  inputs:
    pathtoPublish: '$(Build.ArtifactStagingDirectory)' 

EDIT: Based on @DreadedForet's code, here is what is produced that created with 1 zip (job) with the following in it:

  1. Test Results - empty
  2. a - contains zip for the web project (this is correct)
  3. b - empty
  4. s - seems to be a dump of all the projects source code (content of the dir that the .sln is in)
2 Answers

You only have a publish task for the DotNetCore project. If wanting to publish all the files in an Azure Pipline try replacing the PublishBuildArtifacts@1 task with PublishPipelineArtifact@1 like this. This may not accomplish 100% of what you are trying but should help.

  - task: PublishPipelineArtifact@1
  inputs:
    #targetPath: '$(Pipeline.Workspace)' 
    #artifactName: 'drop'

This will publish everything connected to your pipeline as opposed to just those that have been pushed to the staging directory.

We can disable the option Publish web projects and add specify the project path, such as below.

- task: DotNetCoreCLI@2
  displayName: 'dotnet publish'
  inputs:
    command: publish
    publishWebProjects: false
    projects: 'project path'
- task: PublishBuildArtifacts@1
  displayName: "Upload Artifacts"
  inputs:
    pathtoPublish: '$(Build.ArtifactStagingDirectory)' 

Then add the task again to build a zip for the console app

Related