This is part 3 of our Deploying Websites with Continua CI tutorial. It is highly recommended that you complete both Part 1: Create a Web Application and Part 2: Transform Web.Configs before continuing with this tutorial.
So far in this tutorial, we have created a test web application and dynamically transformed our web.configs. In part 3, we will add our web application to a Version Control System (VCS) and build the project in Continua CI using MSBuild.
When using Continua CI, it is best practice to access any build process elements through a Version Control System (VCS). While we can access our Deploy Web Application through the file system, it is highly recommended that the Web Application is added to a VCS of your choosing.
While you can use any VCS of your choosing, for this tutorial we will be using Mercurial as our VCS. Continua interacts with all VCSs the same way so you can use any VCS for this tutorial.
Go ahead and add your Web Application to a VCS of your choosing.
For this tutorial we will create a new project and configuration in Continua CI. Lets call our project Deploy Project and then create a configuration under Deploy Project called Deploy Configuration(as shown below).
If you need additional help with creating your project or configuration then check out our getting started tutorials, in particular Part 1: Create your First Project and Part 2: Create your First Configuration.
Now that we have our Deploy project and Deploy Configuration, lets link our Web Application to our Deploy Configuration via our VCS.
Navigate to the Repositories page under the Configuration Wizard for our Deploy Configuration. On this page you can link your VCS to Continua CI at either the Global, Project or Configuration level (learn more about Repository Scope). For this tutorial, lets link our repository to the Configuration by clicking the [Create] link next to the Configuration Repositories header.
Clicking the**[Create]** link will bring up the Create Repositories dialog. Using this dialog, enter any VCS specific information that Continua will need to successfully link to your repository. Lets call our repository ContinuaDeployTutorial. For this tutorial I have created a Mecurial repository for our Web Application (as shown below). Once you have entered all your VCS settings, you can click Validate which will determine whether your repository is valid and has successfully been linked to Continua.
Once you have saved your repository, you should then see it appear under Configuration Repositories, as shown below.
Now that we have linked our Web Application to Continua CI, we will need to create an MSBuild action to build our Web Application Solution. For this tutorial, we will run MSBuild over our project twice. Basically before we can package our Web Application, we need to Compile the entire solution, which may include tests, services, etc. Once the solution has compiled correctly, we can then run MSBuild over our website project file. With this in mind, we will need a build process that looks something like this:
While in the Configuration Wizard, navigate to the Stages page. The stages page is where you add your individual build actions to the configuration. It is also where you control the flow of various actions by using if, else, etc. actions.
Once you have navigated to the Stages page, you should see that a Build stage has already been created for you. This stage is created for new configurations by default, however it can be renamed.
Before we can create our MSBuild action, we will need to create an output directory in the Agents workspace. This directory will be where our built ContinuaDeployTutorial solution will be stored. In Continua, it is best practice to store all information relating to a build within the Agent's workspace. This means that all information regarding an individual build is contained within it's own build folder.
So lets create a Create Directory Action by clicking the File Operations Category and selecting the Create Directory Action (As shown below).
This will bring up the Create Directory Action dialog. The only property that we need to set is the Path property, which should be set to $Workspace$\Output\Solution. This is telling Continua to create the Output/Solution directories in the Agent Workspace. This directory will be where we store our Web App once we have built our project.
Once you have saved the action, you will see that your Create Directory Action has been added to the Workflow window in the Build Stage.
Lets go ahead and Create a MSBuild action on the Build stage by clicking the Build Runners category and selecting the MSBuild action. This will add the MSBuild action below the Create Directory action that we have already created.
Selecting the MSBuild action will bring up the Create Action Dialog which allows you to set the parameters that will be used when the MSBuild action is executed. So lets set the following parameters:
Once all these properties have been set, save the action and you should see it appear below our Create Directory Action.
Now that we have created our actions that will build our solution, we need to add another Create Directory action and another MSBuild action that will build our Web Application project.
So lets add another Create Directory action, but this time we want to create the directory $Workspace$\Output\Website (as shown below).
Now we can finally build and package our Web Application so that it is ready to be deployed. Create anther MSBuild action and give it the following properties:
Once we have created all 4 actions, our build process should look something like this:
Once you are happy with your build process, click the Save & Complete Wizard button.
Now that we have created our actions, lets run the build. Navigate to the Configuration page and click the Fast Run button (the fast forward button). Once the build has finished running, it should turn green if it completed successfully.
Once your build has completed successfully, you can see the end result of our build by navigating to your Continua server workspace and finding your build folder. Your build can be found on your Continua server in the following directory: <your_continua_share>\Ws<project_name><build_number>\Output. Navigate to this directory and you should see your 2 directories, Solution and Website. The Solution directory should now contain your built solution while the Website directory should contain your built project and your packaged project. Your packaged project should look similar to the packaged project shown below. It is this package that we now want to deploy to our production server.
Now that we can successfully build our configuration, lets move on the Part 4: Deploy Your Web App where you can learn about deploying your Web Application to your production server.