Azure DevOps: 1 Solution Multiple Projects CI/CD
Asked Answered
O

2

27

I just started setting Azure DevOps with CI/CD. This might not be possible but I hope to find answers.

I have a solution with 6 projects:

  • Web Api project (references Infrastructure, Repositories, and Models projects)
  • Website project (calls the Web Api for data and references Infrastructure, Repositories, and Models projects)
  • Node.js project (only calls the Web Api for data)
  • Infrastructure project (shared by Web Api and Website)
  • Repositories project (shared by Web Api and Website)
  • Models project (shared by Web Api and Website)

Before I start searching on how to publish the Web Api, Website, and Node.js projects to their own Azure App Service within the CI/CD definitions:

Is it possible to set it up so that only certain projects are deployed? i.e.: the Node.js project is published only or only the Web Api and Website are published but not the Node.js.

Or do I need to keep things in different solutions?

If I keep them in separate solutions, how does this affect the shared projects (Infrastructure, Repo, and Models) in reference to Source Control (Git)? If I add code to the Models and Repo in the Web Api solution, do I commit these changes not he Web Api Git repo? How does this affect the other projects that reference the same Models and Repo projects? Is this where Git submodules come into play?

Update 1 (2019/3/8)

Looks like I might be able to get this working in 1 solution using Path filters (https://learn.microsoft.com/en-us/azure/devops/pipelines/build/triggers?view=azure-devops). Still interested in any further input.

Overtake answered 7/3, 2019 at 16:6 Comment(0)
O
21

Hoping this helps others:

I solved this by using Path filters on the Build definition and it works flawlessly. I have created 1 build definition per project that needs to live or be hosted somewhere (in my example, I have 3 Build definitions: Web Api, Website, Node.js).

With the proper path to the project in the Path filter only the proper Builds spin up, and any projects untouched do not trigger a build. Each build has it's own release which then deploys the specified app to it's own destination.

Overtake answered 13/3, 2019 at 18:17 Comment(12)
How did you actually separate the build paths? Is it in the trigger? I tried this, and the build artifact still has the entire solution.Hardboard
@Hardboard sorry for the late reply: it's a 2-part deal. First, in the Agent job, for the Visual Studio build task I defined the Solution to be my project (ie: "\src\Project1\Project1.csproj") for this pipeline. This should guarantee the artifact only contains Project 1. I also then used the Path FIlters entering the same path without the project name (ie: "\src\Project1"). This guarantees that this Pipeline will trigger only when any files within this directory are modified. This is how I understand the process. So far it's worked great and I've added more projects to the solution the same way.Overtake
@Hardboard Let me know if you need more help. I don't mind helping as I know how I've needed it too.Overtake
@RoLYroLLs, thank you for your insight. In my case I have 50 projects, but only 5 are websites. These 5 websites need the DLLs created by most of the non-website projects. If I decide to do what you did, creating 5 build pipelines, I will spend, unnecessarily, a lot of CPU time compiling projects that were already builded. What do you recommend in my case? Only 1 build pipeline and 5 release pipelines?Tildie
@LuisGouveia based on our needs and my research, I only wanted a release to be executed based changes to that website, ie: if 2 out of the 5 changed, only 2 releases should occur. I do believe if you use YAML, you don't have to build it the way I did. I'm not there yet understanding all the features I need to convert to YAML, so I haven't gone there yet. Also, for me, it's 2 pipelines per website: one for "develop" and one for "master" branches, so for my 3 websites, I have 6 pipelines and 6 releases. Yikes! But now that they're done, I haven't needed to do anything and it works great!Overtake
@RoLYroLLs, I ended up creating a single build pipeline for the 5 projects. It creates one single artifact containing the 5 packages. Then, I created also one single release pipeline with 1 task to publish the website on IIS and 5 tasks to create 5 Apps inside that very website. It's working great. Now I need to do the same for Master (this was Dev).Tildie
@LuisGouveia sweet! Does this mean it publishes all 5 websites, even if you only make a change to say, website #1? Just curious, because if so, it won't work for me, otherwise I'd look deeper into it.Overtake
@RoLYroLLs, the short answer is yes, but instead of creating 1 pipeline with 1 artifact with 5 packages, I could have created 5 pipelines with 5 artifacts with the same 5 packages. The build configuration would change, but the release configuration would be a lot similar. In the release pipeline, when you select your Zip, you're selecting a package, not an artifact. If you do this, you'll be able to trigger the right build, but still, not the right release. Everytime 1 build is done, the 5 applications will be republished.Tildie
@Overtake Can you please provide a tutorial or video how can i create a pipeline to deploy multiple(web and webapi) project from a single solution.Sudderth
@LalitRajput I was actually thinking of doing this. How soon do you "need" it? I may not be able to it anytime soon.Overtake
@Overtake I need it urgently, as I'm stuck here. that would be nice if you can provide it ASAP. thanksSudderth
@Overtake can we try without using path filters actually tried build pipeline with (web and webapi) from a single solution by just adding project path in task and didn't enable continuous integration also.But am getting same build numbers for both web and web api pipelines is it valid?Amatruda
B
1

Look if I understand your question well, you need to deploy specific built parts Yes you can do this in azure DevOps. In Azure DevOps you have build definition and release pipeline. In build you will build the projects and publish just 2 components which you mentioned and in release you will deploy them I hope I answered your question

Brew answered 7/3, 2019 at 16:55 Comment(3)
Thanks. But it's more like this: today I change Project1, so when I push to Azure DevOps, I only want Project1 to build and deploy. Tomorrow I change Project2, so when I push to Azure DevOps, I only want Project2 to build and deploy. Currently, all projects are on the same Git Repo.Overtake
sorry for being late, but definitely creating 2 pipelines with path filter for each one will help you. I've the same and this scenario works with meBrew
no problem. That's exactly how I fixed it and it worked. thanks againOvertake

© 2022 - 2024 — McMap. All rights reserved.