Introduction
With the move to cloud-based services, even project development has gone to the “clouds”. Microsoft now offers Visual Studio Online, which supports all aspects of project development in the cloud. In earlier articles http://www.codeguru.com/tools/beginners-guide-to-visual-studio-online.html and http://www.developer.com/microsoft/managing-projects-backlog-with-visual-studio-online/, we got some insights into the offering.
In this article, we will explore how we can actually code and build using the new “Visual Studio Online” offering.
Hands On
For our hands-on experience, if you have not signed up for Visual Studio Online, please do so before proceeding. Go to your Visual Studio Online account and create a new project (if you do not have one already).
Figure 1: Creating a new project
Click the “Create Project” button to create the project.
Next, if you have not installed the Visual Studio 2013 Update 2, please install it now. Next, we will create a demo application in Visual Studio 2013 and configure it to have our source code hosted at Visual Studio Online.
Fire up Visual Studio 2013, and create a new Windows Desktop console project titled “DemoConsoleApp”. Make sure you have the “Add to source control” checkbox checked and click OK.
Figure 2: Creating a new DemoConsole app
Select Team Foundation Version Control when prompted to select the source control system for the new project.
Figure 3: Choosing the source control
Select the Project we created in Visual Studio Online and click OK. If the mapping of the project hasn’t been done before, you will be asked to map the Visual Studio Online project to a local workspace.
Figure 4: Adding the app to the demo
Our project is now created locally.
At this time, we should, as a best practice, commit the project to the source control. To do that, go to Team Explorer.
Figure 5: In Team Explorer
Your team explorer window will appear as shown in Figure 6.
Figure 6: The Team Explorer screen
Click the Pending Changes link to view the open changes that need to be committed.
Figure 7: The Pending Changes screen
To commit the code, we have the option to get a code review or skip and commit it directly. For our demo, we will commit directly.
Enter a comment and click the “Check In” button. You will be asked to confirm the commit.
Figure 8: The Check-in Confirmation screen
Click Yes to proceed with the commit. Once the commit is successful, you will not see any open changes. Next, we will set up “building our changes” in the cloud.
Building in the Cloud
Go to Team Explorer Home and click Builds.
Figure 9: The Builds button is available
You will see the Build view.
Figure 10: The Build view
Click “New Build Definition” to start creating a build definition. We will see the workflow step to creating a new build definition.
Figure 11: Creating a new build definition
We can define the trigger for auto builds, but select “Trigger” now. For our case, we will make this “Continuous integration” to build the changes after each check-in.
Figure 12: Defining the trigger for auto builds
Click the Save button to save the build definition.
Next, we will make code changes and commit it to see the automated build step in action. We will intentionally cause a build-break by missing a “;” at the end of the statement.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DemoConsoleApp
{
class Program
{
static void Main(string[] args)
{
Console.Write("hello")
}
}
}
Check in the new change. Open the Pending changes view on Team Explorer and click “Check in”.
Figure 13: The Pending Changes window
Next, we will visit the Builds view on Team Explorer to check the status of the build.
Figure 14: Checking the status of the build
After a few minutes, we can see that the build failed.
Figure 15: The build has failed
Double-click on the build to see the details.
Figure 16: Viewing the details
We can see that the error is due to a missing “;” at the end of the statement. We also can see that a new bug 36 was created because of the build failure.
Figure 17: Observing the error message generated by the build failure
Now, let us fix the build break.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DemoConsoleApp
{
class Program
{
static void Main(string[] args)
{
Console.Write("hello");
}
}
}
And Commit the changes. When commiting, make sure to associate the change with the bug # as shown below.
Figure 18: Committing to the changes
Click Check In to commit the code. We can monitor the progress by double-clicking the build.
Figure 19: Monitoring the progress
After a few minutes, we can see the progress of the build and see that it completed successfully.
Figure 20: A successful build
Summary
In this article, we learned about building applications in the cloud using Visual Studio Online.
About the Author
Vipul Patel is a technology geek based in Seattle. He can be reached at vipul.patel@hotmail.com. You can visit his LinkedIn profile at https://www.linkedin.com/pub/vipul-patel/6/675/508.