November 18, 2015

283 Views

Continuous Integration using Visual Studio Online

Continuous Integration is a software development practice to integrate developer codes into a large code base frequently, usually several times a day. Continuous Integration helps to verify automated build with basic test scenarios and Code analysis.

In this article, Git has been used for version control and code repository, while Visual Studio Online (VSO) for Continuous Integration.

Git Installation

  1. Open the command prompt (run as admin)
  2. Install chocolatey machine package manager.
  3. Open the PowerShell editor(run as admin)
  4. Install Posh-Git with chocolatey

PS C:\> cinst poshgit

  1. Once installed, close the Powershell editor, and reopen it.
  2. To verify type “git” and enter.

Setup VSO

  1. Create a Microsoft account, if you don't have one.
  2. Sign in to Visual Studio Online with your Microsoft account (for example, @outlook.com or @hotmail.com).
  3. Click on New link to create a new team project

  4. It will pop up with ‘new team project’ page

  5. Add Project name and Description
  6. Select Process template
  7. Select Git as Version control
  8. Click on Create project button
  9. It will create new project under DefaultCollection

  10. Click on Administer account settings

  11. Click on Agent Pool
  12. Add your live account in the Agent Pool Administrators

Add Visual Studio Project in Git & VSO

  1. Created Hello World Web, test and database projects in Visual Studio 

  2. Open powershell editor
  3. Go to local project folder location
  4. Type git init command to created git repository

    >git init

  5. Add user name and email  in the git config

    >git config –global user.name “Gaurav Srivastava”

    >git config –global user.email “Microsoft email”

  6. Add remote VSO url

    >git remote add origin “VSO project url”

  7. Add all the project files into git

    >git add *.*

  8. Use commit to add files from staging to local repository

    >git commit –m <message>

  9. Use push to add files from local repository to VSO repository

    >git push –all

  10. It will ask for VSO credential and password
  11. Open the VSO project url
  12. Click on Code tab
  13. Now your code is available under your team project and you can see all 3 (web, test and database) projects.

Continuous Integration using Visual Studio Online

In this section, we will do Continuous Integration with Visual Studio Online.

  1. Sign in to VSO with your Microsoft account.

  2. Click on BUILD tab
  3. Click on ‘+’ action to create new build definition

  4. Select Visual Studio in the Build template and click on OK button.

  5. New build definition template will open

  6. Select Continuous Integration option from Triggers 

  7. Select Default queue as Hosted

  8. Click on Save button
  9. Enter build definition name and click OK.

  10. Now ‘New Build’ is available under Build definitions

  11. Open Visual Studio TFS and connect to DemoVSO project

  12. Select Hello World solution
  13. Add your change in the files
  14. Save it
  15. Build the solution
  16. Right click on solution and select Commit

  17. It will ask to publish your code first.
  18. To publish, pass the VSO project url.
  19. Enter the comment in message box and select Commit and Push option. It will commit and push your changes to VSO.

  20.  Navigate to VSO under Build tab
  21. Select New build under build definition
  22. Once you build is successfully completed, It will be visible under the completed section

  23. Click on Build
  24. It will give you build details view

  25. Click on Artifacts to get the build drop location. You can download/ Explore the build

References

  1. Visual Studio Online - https://www.visualstudio.com/en-us/products/what-is-visual-studio-online-vs.aspx
  2. Git - https://git-scm.com/