18

In my solution, I have two projects (a Asp.net MVC and a Windows Service). I want to create CI/CD pipeline to deploy web application and windows service on different VMs. But to achieve this my CI pipeline should be able to publish artifacts separately for both project and then I can feed these artifacts in CD pipeline for deployment. How artifacts for all projects can be published separately in a CI pipeline ?

PS: If I create two solutions each with one project only and create CI/CD pipeline separately, all works fine. But I want to achieve it with solution having multiple project as mentioned above.

DevX
  • 725
  • 3
  • 13
  • 26

3 Answers3

12

You can use multiple, Publish tasks to create multiple artifacts in a single build definition.

For example lets say, you have below, as your current artifacts for a single project, comprising of _PublishedWebsites\MVS5WebApp (XCopy deployable website) and _PublishedWebsites\MVS5WebApp_Package (web deploy package).

Current Artifact

If you want to separate these two, into two artifacts, you can use two Publish Artifact tasks as shown below, each one specifying exact path to publish (this path does not support wildcards, you just have to specify the folder you need to publish) Publish website XCopy deploy content

Publish Web Deploy Package

This will give you output as shown below. Two Artifacts

In this example I just only used the Publish Artifacts task and created two artifacts using a single web site project. You can do same for your two project scenario. If you want to use wild card to filter more files before publish you can use "Copy File" task multiple times as required.

ChamindaC
  • 1,452
  • 10
  • 10
  • Is there any difference for aspnetcore projects ? – k11k2 Jan 12 '18 at 13:03
  • 1
    How do you build and deploy two web projects to the artifact staging directory so they can be published as a single artifact (or multiple as in this case)? I can make it build the entire solution, but once I try to use the deploy/package feature to get transformations of the web.config file I am only able to get a single project as output in the artifact staging directory – MartinF Jul 16 '18 at 12:58
  • @MartinF did you ever figure out how to do the build? – cal5barton Nov 13 '18 at 22:24
  • @cal5barton: Ended up building each project separately to $(Build.ArtifactStagingDirectory)\\{ProjectFolder}, and publishing a single artifact with all of them. – MartinF Nov 25 '18 at 15:33
7

If you are using '.net core' task in the build pipeline then uncheck the checkbox 'Publish web projects' just after the command textbox.

Then it automatically creates publish artifacts separate for each project in the solution with the same name as each of the project files.

Ram
  • 15,908
  • 4
  • 48
  • 41
  • @Ran I have multiple projects in one solution. Problem is I am changing one project but building and releasing all projects. But I want if one project change then only that project will release. How do I manage it? Remember I am using .net core project. Generating all artifacts. – Noor All Safaet May 29 '20 at 23:46
  • @NoorAllSafaet In your scenario its best to create separate repositories -- so you build & release only what is required. – Ram Jun 02 '20 at 08:54
0

You have multiple ways to achieve that.
You can either create multiple build definitions targeting the project and not the solution in the build step with the proper arguments.
Or you can have one build definition with multiple build steps.
After that on the release side of things you can either leverage one release definition with multiple steps or multiple release definitions.

baywet
  • 4,377
  • 4
  • 20
  • 49