In most of the cases the solution of your application contains more than one project for example one or more web app, function app, WCF service, web API. When you build the solution you will get the predefined folder structure in the artifact. But sometime you might need to publish the different project to some user defined folder structure rather than the default folder structure.
In this article we will discuss how you can have complete control over where you want your projects to be placed while publishing the code.
- Add the MSBuild task in your build pipeline if , either you have not one already or you have one MSBuild task which builds you whole solution.
- Select the necessary settings in the new task as shown below. In the project tab you need to select the project that you want to build separately and publish to a different folder.
- Use $(BuildConfiguration) in the Configuration section.
- BuildConfiguration can be configured in the variable section as per the need.
- MSBuild Arguments field is the one which will help you publishing your code to the folders that you want. Put the below mentioned setting in the MSBuild Arguments section.
Below is the screenshot for your reference.
- Build.ArtifactStagingDirectory is the predefined build variable which stores the local path on the build agent where any artifacts are copied to before being pushed to their destination. For example:
You can publish different project into different user defined folder by following the above mentioned steps. But what happens when the folder you want, is not part of the solution. For example if your SQL scripts or power shell scripts are not part of the solution but you need them in your artifact, you can achieve that as well. It is discussed in detail in my next article.
Happy learning . 🙂