DevOps

  • Hosting a ASP.NET Core application in a Docker container using microsoft/aspnetcore image

    You all will be familiar with Docker by now given its popularity among developers and infra people and some of you may have already created containers using Docker images. One of the most widely used workflows among people using .NET Core will create a new web application by using the dotnet new command as shown below.

    The below example uses ASP.NET Core 2.0 framework, in which the dotnet new command will create the project as well as restores the dependencies specified in the csproj file by default. I have already written a post about it and you can refer it for information about it

    Then you will do a build to see if there are any errors and use dotnet run command which will self-host the web application


  • Visual Studio Team Services : Adding and Running Unit Tests on Every Build

    In the previous post in Visual Studio Team Services series, I have explained the steps triggering a build in the Team Services portal whenever we check in the code and in this one, I am going to show you the steps needed for running unit tests when a build is done in the portal.

    Setting up Unit Tests in your solution

    Let's modify the program I used in the earlier post as shown below.

     public class Program
        {
            static void Main(string[] args)
            {
                int i = 1, j = 2;
                int c = Add(i,j);
                Console.WriteLine($"Sum of {i} and {j} is {c}");
                Console.ReadKey();
            }
    
            public static int Add(int Num1, int Num2)
            {
                return Num1 + Num2;
            }
        }
    

    Added a new method for adding two numbers and returns the sum back to the calling function. Now, I am going to create a unit test project and will create a test method for testing the newly added method.

    Right click on the solution to bring up the context menu and then select New Project from the Add menu item


  • Visual Studio Team Services : Triggering Build

    So for in this series I have shown you to configure Visual Studio Team Services for hosting code in the portal as well as to create build definitions which can trigger the build whenever the code is checked into our remote repository. In this post I am going to show you how to trigger build process by checking in code. Before that, if you want to have a recap of items which I have mentioned above, please go through the links given below.

    1. Visual Studio Team Services : Hosting Your First Project Using Git From Visual Studio

    2. Visual Studio Team Services : Creating Build Definitions

    Adding Code and check in changes to local repo

    I have hosted the code in the remote repository and has the build definitions in place. Let's make some changes in the code and check it in to local repo first and then push it into the remote repo to trigger the build.

    If you remember from my earlier post that I have checked the main method without any statement in the Program.cs file in our console application. Let's add a Console.WriteLine statement in it as shown below.


  • Visual Studio Team Services : Creating Build Definitions

    In the one of the earlier post in the blog, I have showed you how to host your project in Visual Studio Team Services. In this post, I am going to show the steps needed for creating a build definition in Team Services so that whenever we checks in the changes it will trigger the build process automatically.

    Creating Building Definition

    You can create a new build definition from either the dashboad or from Build page or from the Code page. In the code page it will show a link to set up the build process along side the name of the branch if it's not setup as shown in the image below.

    When you click on the setup now,  a dialog box will be shown containing the list of build templates available in Team Services. Select the Visual Studio template from the list and click on the next button.


  • Visual Studio Team Services : Hosting Your First Project Using Git From Visual Studio

    Visual Studio Team Services is the new name for Visual Studio Online which was a collection of all the online services of Visual Studio. But the name "Visual Studio Online" was very confusing, many people thought that it's a web version of Visual Studio. So they decided to rename it as "Visual Studio Team Services" bringing along some new features with it too. You can read more about setting up Visual Studio Team Services Account, its features and pricing from here.

    In this post, I am going to show you how to host a repository in Visual Studio Team Services, store and collaborate code from Visual Studio.

    Creating Project

    Let's start by creating a new project from the Team Services Dashboard by clicking on the New link.

    Give a name and description for the project in the modal window, select Git for version control and process template as Agile and click on the Create New Project button.