B Roy
B Roy

Reputation: 37

How to publish a specific project from a vs web solution of multiple projects in azure devops artifact

I have multiple projects inside a single web solution in visual studio. I have uploaded my entire solution in DevOps. Now I want to publish a specific project in artifact (not all the projects). Please let me know how can I do that. And also what specification is required in YAML files for this task?

Upvotes: 2

Views: 2960

Answers (2)

Krzysztof Madej
Krzysztof Madej

Reputation: 40899

Here in project you should set your specific project which needs to be published:

# Publish projects to specified folder.
- task: DotNetCoreCLI@2
  displayName: 'dotnet publish'
  inputs:
    command: publish
    publishWebProjects: false
    projects: 'MyDirectory/MyProjectToBePublished.csproj'
    arguments: '-o $(Build.ArtifactStagingDirectory)/Output'
    zipAfterPublish: true
    modifyOutputPath: true

Please remember about publishing pipeline artifacts.

If you want to publish all projects you need to change projects input to this **/*.csproj

steps:
# Publish projects to specified folder.
- task: DotNetCoreCLI@2
  displayName: 'dotnet publish'
  inputs:
    command: publish
    publishWebProjects: false
    projects: '**/*.csproj'
    arguments: '-o $(Build.ArtifactStagingDirectory)/Output'
    zipAfterPublish: true
    modifyOutputPath: true

- task: PublishBuildArtifacts@1

and then you will get it multiple project published as artifacts:

enter image description here

Upvotes: 3

Yu Zhou
Yu Zhou

Reputation: 12999

How to publish a specific project in artifact?

You can search “publish artifact” task in your YAML review page then click the Publish build artifacts. Set the Path to publish to the path of the project you want to publish then add this task to YAML. You can also refer to my screenshot about the steps.

What specification is required in YAML files for this task?

We can add two triggers in YAML to specific the path of the project we want to include or exclude.

When we specify paths, we must explicitly specify branches to trigger on. You can't trigger a pipeline with only a path filter; you must also have a branch filter, and the changed files that match the path filter must be from a branch that matches the branch filter.

For more information, you can refer to this doc.

YAML trigger:

# specific path build
trigger:
  branches:
    include:
    - master
    - releases/*
  paths:
    include:
    - docs/*
    exclude:
    - docs/README.md

Upvotes: 0

Related Questions