Search code examples
.net-coreazure-devopsazure-pipelinesazure-pipelines-build-taskazure-devops-pipelines

How to exclude folders/projects from dotnet core publish task in Azure Build Pipeline (Classic version)?


I have an Azure DevOps GIT Repo with three different types of projects. Structure looks as follows;

Repository Structure

I have a Build Pipeline (Classic, not YAML) to build only the .Net Core Project as below.

Pipeline

The pipeline settings is pointed to consider only the NetCoreProject. The Restore, Build & Test tasks executes successfully. However, when it comes to the 'Publish' task the pipeline fails as it considers the entire repository (all projects) and not just NetCoreProject.

Actual cause of failure is in NetCPPProject folder there are some files without any extension (makefile, shortcut files, etc.) which the Publish task is not identifying and failing with below error.

##[error]Error: Failed find: ENOENT: no such file or directory, stat 'D:\a\1\s\NetCPPProject\inc'

Note: inc is a shortcut file (without any extension) and it is required to be present in the folder.

I tried following which did not work;

  1. Added .artifactignore to ignore other folders but the .Net Core 'Publish' task seems not to consider that.
  2. Tried specifying the arguments to Publish tasks to consider only the NetCoreProject .sln file and also .csproj file, but issue still occurs with same error message.
  3. Reconfirmed the file exists in Build.SourceDirectory with a command line task.

Question is, how to make .Net Core 'Publish' task to exclude NetCPPProject and only consider NetCoreProject?


Solution

  • how to make .Net Core 'Publish' task to exclude NetCPPProject and only consider NetCoreProject?

    To achieve this goal, you could try the following steps:

    Step1: Disable Publish web projects option in Dotnet Publish task.

    Step2: Set the target csproj file in Path to project field

    enter image description here

    For example:

    Repo:

    enter image description here

    Result:

    enter image description here