1
votes

I have a .NET Core 3.1 solution that contains 2 Web Application projects. I am using Azure DevOps Pipelines for CI/CD and so I have the build-test-publish steps defined in an azure-pipelines.yml file.

The task that I am using to package the products of my two web application projects is fairly standard and based on the DotNetCoreCLI@2 task:

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

So far so good. This step creates two zip files, one for each web application.

But, having added a new Azure Functions project to my solution, its products are not zipped in the same way. As a result, I am unable to deploy it to Azure.

I guess the task defaults to only publishing Web Application projects. How can I make it also work on my Azure Functions project?

1

1 Answers

1
votes

It seems that when one sets publishWebProjects to True, as I have, then the publish command for DotNetCoreCLI@2 will only publish web application projects. Which, I now come to realize, is rather obvious.

The solution I've found for my need is to set publishWebProjects to False and also add projects: '**/*.csproj'.

- task: DotNetCoreCLI@2
  inputs:
    command: publish
    publishWebProjects: False
    projects: '**/*.csproj'
    arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
    zipAfterPublish: True

Now the task creates a zip file for every project in my solution. This includes a few test projects, but I don't mind. If one does mind, one could likely list only the specific projects to be zipped in the projects attribute.