Azure Build Pipelines publish multiple webapps in same solution - azure-devops

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.

Related

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

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)

.NET Core 3.1 API fails when using DevOps CI/CD

Deploying a .NET Core 3.1 API Application to an Azure WebApp fails when using DevOps CI/CD Release Pipeline but succeeds when Publishing from Visual Studio
Create .NET Core 3.1 Api App
Create Azure Web App
Create a new resource of type “Web App”
Publish from Visual Studio
Ok, so that works, now here's what happens when trying to deploy using DevOps CI/CD Release Pipeline..
Deploy via DevOps CI/CD
… create another Web App resource junk-devops-cicd ...
deploy via ci/cd pipeline
Create the Build Pipeline
Create the Release Pipeline
So it fails going through CI/CD pipeline. But not VS Publish Manager
If the first pipeline you created is a CI pipeline (Build pipeline) you need to select the "ASP .net" template not the "Azure web App". this pipeline will restore nuget,build and publish the artifact of your app in the artifact store of AzureDevops. Then your release pipeline will get this artifact and deploy it into Azure.
the "Azure web App" template is a CI/CD template.
I think the mistake you have mad is deleting some essentials steps for building a package, "Use Nuget" and "Nuget restore".
To build an artifact correctly you need to have those steps:
Asp .net build pipline
Your .net core application build task is wrong. i guess solution is not getting build successfully . try visualstudio build instead of netBuild
And make sure your Artifact Build directory path been set correctly. root path should be $(Build.ArtifactStagingDirectory)

How to publish build artifacts to external organisation using Azure DevOps?

I have an ASP web application that I have building in an Azure DevOps Build Pipeline. That is all fine.
I want an external organisation to be able to define their own Azure DevOps Release Pipeline to consume the build artifacts produced by our Build Pipeline. I need the access of that external organisation to be restricted with some sort of credentials (i.e. I don't want the project to be public to everyone). The external organisation should be able to deploy the latest version.
I thought this would be a relatively simple process using only Azure tools (particularly with reference to Feeds), but have tried a number of different approaches based on the documentation but all have failed. I don't want to publish to GitHub - I just want to keep everything inside Azure. I have tried using Universal Packages with Feeds, but the Release Pipeline can only pull a specific version from the feed rather than LATEST.
Does anyone have any recommended approaches I should take?
There is Latest option in the feed of your Release Pipeline:

How to combine multiple azure artifacts to one web deploy in the release process

I have a website which is the combination of 3 separate artifacts.
The base files for Sitecore (a CMS, best practice is to keep it separate from your own code repo), this artifact is just files
The custom logic for the web site (.net) which is compiled into a web deploy package
An additional module that we only release to the dev server. This artifact is just files (2 dll's and a config file)
At the moment to deploy to our dev server I have 3 IIS Web App Deploy tasks to release to IIS on a VM. The first removes the existing files and publishes one artifact and the next 2 just publish the additional artifacts.
However this feels really wrong and that it should all be done in one task. It's also not particularly fast having 3 separate processes to deploy files.
How can I set this up better? Speed is a big concern as this would currently take the site out for about 10 minutes while the deploy happens.
combine multiple azure artifacts to one web deploy task in the release
For this issue,I think one 'IIS web app deploy' task could not achieve this feature.
I test with the wildcard provided by default: $(System.DefaultWorkingDirectory)\**\*.zip
Then I get this error:
From the error message ,it presents that we can not select more than on package with the search pattern, I think this could be due to the limitation of 'IIS web app deploy' task, only one artifact can be specified in an 'IIS web app deploy' task. At present, to deploy multiple artifacts can only be achieved through multiple deploy tasks.
You can make your request to the IIS Web Application Deployment task in git hub.

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.