What do we use in Azure Dev a project or pipelines per solution - azure-devops

Help needed with azure pipelines. Just testing it and consider migrating from TeamCity to Azure Dev and was wondering:
I have:
1. Asp.Net Core Web Api (Web1)
2. Asp.Net Core Web Api (Web2)
3. WPF App
4. Several infrastructure class libraries that are shared libs between the above 3 solutions (Web1, Web2, WPF).
Do I create 4 azure projects?
1 project that includes the repository of Web1 project with 1 pipeline that nuget restores, builds and publish artifacts
1 project that includes the repository of Web1 project with 1 pipeline that nuget restores, builds and publish artifacts
1 project that includes the repository of WPF App with 1 pipeline that nuget restores, builds and publish artifacts
1 project that includes all repositories of all class libs and for each library I create a pipeline
or I create one project for all and add one pipeline for each (web1, web2, wpf apps and class libs)

Writing the comments as an answer so that we can close the question.
Are those .NET projects located on different git repositories? Is your git tool Github or Azure Devops repos?
Personally I use projects to seperate different logical projects (development teams) and different pipelines inside the same project for different projects of the team.
For example team A could have 4 projects, I would go for one DevOps project and 4 pipelines inside it. Team B would have a separate project etc.
Shared libraries can be handled the same way as different projects. You can build them and upload them through a task on nuget. If they should be included on the projects, there should be already on your web1,web2 and wpf projects, as a result the pipeline that will execute msbuild and nuget restore will handle the libraries also.
If you do not want to eliminate some projects to specific people, then I would go for one DevOps project and different pipelines for each library project.
In general you combine the pipeline with a github repository. As a result if all your libraries are placed inside one github repository you will go with one pipeline, else you have to create multiple pipelines inside the same Azure Devops Project.
In general the approach that I mainly use:
Different Azure DevOps projects -> Different dev teams.
Projects inside one dev team -> Different pipelines inside the project.
Different github repositories -> Different pipelines for each one (exceptions apply here but in most cases it is a practice)

Related

Azure Build Pipelines publish multiple webapps in same solution

I am new to Azure Build Pipelines.
I've seen many posts and videos about how to create a simple pipeline using the Azure Devops UI (no YAML), with one Web Application project, but I have 2 applications, an asp.net Core Web Application (WebUI) and an asp.net Core Web API. For some reason, the artifact published from my build pipeline is only containing the WEBUI. I would expect that both projects be published as Artifacts.
Any suggestion on what I should do to have both artifacts as results from my build pipeline?
Thanks
I actually found my issue. I had a checkbox in the Publish Task called "Publish Web projects".
Once I unchecked it, both my artifacts were created.

Publish multiple projects - AzureDevOps

Sure this will be an easy one - but when creating a pipeline for a solution that includes 2 projects, one with and without wwwroot only the web project gets published. How do we publish all projects?
Normally we have at least two directions:
Create multiple pipelines (two CI pipelines or two CI and two CD pipelines), one for ProjectA and the other for ProjectB.
Create one pipeline with multiple publish steps. So you may have two Publish tasks in same pipeline, one to publish ProjectA and the other to publish ProjectB.
But since it's unclear the project type of your projects, and which task do you use the 'Publish', you may get help help from these tips:
If the publish you mean is Publish Artifact, check this issue.
If the Publish you mean is to deploy the projects to something like Azure App Service, also you're using the Azure App Service Deploy task:
You can copy the ProjectA and ProjectB's outputs to same path, and set the value of PackageOrFolder to that path. (If the two projects have dependency relationship, so you may need to publish two projects together to same path?)
Or just use two Publish tasks. Use the Publish task you used to use for publishing the web project. To publish the non-web project, you may need a different publish task? (Not sure about the project type and what place you want to publish to, I'm not sure about the task you should use).

Triggering Build on Package Update

I'm looking for options that would allow us to trigger/queue builds (XAML Build Definitions within Azure DevOps) when a new package is available in either Azure DevOps Artifacts or Artifactory.
We've developed a common framework library, which we build, package and post to a NuGet Repository (either Artifactory or Azure DevOps Artifacts). Naturally, each time we post, we increment the version number: x.y.z.n, x.y.z.n+1, x.y.z.n+2...
We also have other components which reference this common framework using NuGet Floating versions: x.y.z.* Some of these components have interfaces that other components also reference and so on.
We want to trigger the rebuilds of components when a new version of a referenced package is posted to the repository.
For example: If a change to our Common Framework is made and a new version (x.y.z.15 for example) is posted to the NuGet Repository, we want to trigger/queue all the other builds which reference the Common Framework Package Version x.y.z.*.
We've been looking for existing tools to do this but so far no luck. Here are some ideas/strategies we have:
1) Does something exist or could something be built to subscribe to a Library in a Repository, that build could be triggered when a new version appears
2) Should we build a list of all the package references and builds which need to be triggered somewhere and write a program to do this.
3) Can we chain builds within Azure DevOps or can they subscribe to successful builds - forget about the Repository - just trigger from successful builds of the components you depend on... everything is in the same Azure DevOps code repository.
While we're using Azure DevOps, we're not using the GIT repository, we're using the older VS Repo and we've got the older XAML builds, not the Pipelines yet.

VSTS How do we trigger automated build of one project when there is a checkin in another project

In VSTS I have 2 Git projects (ProjectA,ProjectB). If ProjectA is updated then automated build is triggered. I would also like ProjectB to trigger also after ProjectA. How do I configure this in VSTS?
I check the trigger section but I not Build completion Add option is disabled. Is this the feature I should be using?
Although the build system supports chained builds, those builds must reside within the same team project. Team Projects are intended for isolation of unrelated resources with no dependencies. Since you have dependencies between these repos, ideally, they should not be in separate team projects.
Some options:
Script it using the REST APIs.
Make a build definition in Team Project A for the repo hosted in Team Project B, then use chained builds.
Host your related repos and build/release definitions in the same team project.

How to publish artifacts separately for each project in solution from VSTS CI pipeline?

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.
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).
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)
This will give you output as shown below.
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.
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.
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.