Articles and tutorials on ASP.NET MVC, Kendo UI, Windows 10, Windows Phone, Windows 8, Orchard

  • Create and Run a Sample C# Program Using .NET Core RC2 Image in Docker

    You all may be knowing that Microsoft is in the process of rebuilding the .NET framework from the scratch to embrace the rapid advancements happening in the technology world. Last week they released the RC2 version on .NET Core which is vastly imporved from the last release with more APIs and performance improvements. You can read more details about the changes in one of the posts I have blogged earlier here.

    In this post I am going to show you how to make use of the Docker container images for .NET Core to create and execute a C# program in Docker. Meaning I am not going to install the framework in my machine, rather host the runtime in a docker container and use it for compiling and running the program.

    So one of the pre-requisite for this procedure to work is to have Docker installed in your machine. I am going to use a Windows 10 machine for this example and I have the latest Docker for Windows Beta installed in it. Please read my earlier posts on how to install Docker for Windows Beta in your machine and to troubleshoot the issues which may come up during the installation.

    1. Installing Docker For Windows Beta
    2. Docker : Troubleshooting Installation Issues

    Downloading the Image and Running the Container

    The first step is to download the RC2 version of the image from the Docker Repository. You can use the following command in the powershell window for that. It will download the image and runs the container when the download is completed.

    docker run -it microsoft/dotnet:latest

    It will pull the latest version, that is RC2 in our case from the repository and once it completes the download you will get a bash shell prompt, from where you can execute the CLI commands. You can refer the Microsoft repoository in Docker to know about more options such as downloading a specific version etc.

    Categories: DotNet CLI, Docker

  • .NET Core RC2 Released with Some Major Changes

    Early this week Microsoft has released the .NET Core RC2 which includes some significant changes to the core framework and is a major update from RC1 which was released in November. RC2 includes a new set of APIs and tools along with performance and reliablity improvements.

    RC2 contains updates to the following components

    .Net Core RC2

    ASP.NET Core RC2

    .NET Core RC2 SDK Preview 1

    You can read more about the RC2 release of .NET Core here.

    One of the major change is with the Dotnet Execution Environment(DNX), which is now termed as .NET Core SDK in RC2. DNX was released with RC1 which included a runtime and a toolset to build ASP.NET Core 1.0 applications. It consisted mainly of three parts.

    DNVM - install script for obtaining DNX

    DNX - DotNet Execution runtime for executing the code

    DNU - DotNet developer utility, for managing dependencies, building and deploying applications. 

    In RC2, all these three are now part of a single toolset called .NET CLI(Command Line Interface) and features provided by these tools are now available out of the box.

    DNVM & CLI

    DNVM or DotNet Version Manager was used to install DNX on your machine. It was used by users to download specific versions from the specified feed as well as to make a runtime active etc.

    .NET CLI doesn't have an equivalent command for this, instead it comes in two types of packaging

    1. Native installers for each platform
    2. Install Scripts

    With Native installers, CLI is distributed as installers such as DEB packages for Ubunutu, MSI bundles for Windows etc. These will install the CLI and setup the environment so that the users will be able to get started with CLI immediately after the install. One disadvantage of this approcah is that the user will require administrative privileges for installation.

    Install scripts doesn't need eleveted privileges, but the user will need to manually install the pre-requisites before installing the CLI.

    You can refer the here for more on the .NET CLI installation process.

    Command List

    In DNX, we were using dnx or dnu before the commands, but in CLI, we will have only one prefix called dotnet. So to run our program from the command line, we are going to use dotnet run instead of dnx run command. Given below is the list of common commands used in DNX and it's corresponding ones in CLI

    DNX Commands CLI Commands
    dnx run dotnet run To run the compiled file
    dnu build dotnet build Build the source code into IL
    dnu pack dotnet pack To build your source as a NuGet Package
    dnu restore dotnet restore To restore the dependencies/packages defined in your project.json
    dnu publish dotnet publish Publishes your application for deployment

    Some of the commands omitted from CLI are

    1. dnx [command] , for eg dnx web
    2. dnu install
    3. dnu wrap
    4. dnu commands

    Development Workflow

    The simplest form of workflow for developing apps using .NET core is to create a new project, restore the dependencies and then build and run the app using the following commands

    dotnet new

    dotnet resore

    dotnet run

    Please read the post Announcing .NET Core RC2 and .NET Core SDK Preview 1 from .NET blog to know more about the changes and features in .NET Core RC2

    Categories: DotNet CLI

  • Docker : Troubleshooting Installation Issues

    In the earlier post, I have detailed the process of registering for private beta program and installing the beta version of Docker in Windows machine and in the last part I have mentioned that I faced some issues while initializing the Docker in my machine. In this post I am going in detail about the issues faced and the steps I took to resolve it.

    After the installation, when I launched the Docker instance,it showed me an error saying that there is not enough memory to start Docker after some time.

    My machine was running on Windows Insider Preview build 14295 which has got only 3 gigs of memory. So, I closed all the unwanted applications which was consuming a lot of memory and was able to bring down memory usage to 50%. 

    Enabling Hypervisior

    When I started the Docker again, the above error went away but got another one this time saying that the VM cannot be started because the hypervisor is not running.

    Categories: Docker

  • Installing Docker For Windows Beta

    Containers are gathering pace these days and many more companies are moving their virtual machines to containers at a faster rate. Docker is built on top of Linux Containers(LXC) which has got it's own file system, storage, RAM and CPU.  One of the key differentiator with the Virtual Machines is that VM's emulate hardwares virtually, which itself consumes resources and comes down heavy on the underlying OS, but the advantage is that we can install any guest OS inside VM's. But with containers such as Docker it uses a shared OS which means that all the containers in a machine should have the same OS, advantage being that, by sharing it can utilize the resources more efficiently and will be light when comapred to virtual machines.

    While celebrating their third birthday, Docker announced a beta program of Docker for Windows and Mac which contains an integrated environment for building, assembling and shipping applications for Mac and Windows. For more details, refer this excellent blog post by  announcing the release of the beta program for Windows and Mac.

    This is a limited beta program from Docker and is not open to all. First you need to go to beta.docker.com and sign up using your Docker ID. Once you are successfully validated, you are redirected to a page where you can fill up the information as shown in the below screen grab.

    Categories: Docker

  • 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

    Categories: DevOps, Visual Studio Team Services

  • 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.

    Categories: DevOps, Visual Studio Team Services

  • 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.

    Categories: DevOps, Visual Studio Team Services

  • 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.

    Categories: DevOps, Visual Studio Team Services

  • Visual Studio Tips & Tricks - Window Layouts

    Another neat little feature available in Visual Studio is the option to customize the window layouts. This comes in handy when you work on different machines and you want the same look and feel for the enviroment across all your devices and instances. 

    For this to work, first you need to log in with the Microsoft account while using Visual Studio, so that whatever changes you make for customizing the layout will get stored in the cloud and will be used to synchronize the layout across devices.

    Let's see how we can manage layouts using Visual Studio. I prefer to have least tabs open in the IDE and likes have the code editor uses most of the layout. So I have closed all the open tabs in the right side as well as in the bottom.

    Saving Layout

    Now we can save out layout from Window -> Save Window Layout.

    Categories: Visual Studio, Visual Studio 2015 Tips & Tricks

  • Enabling Search in your Blog Posts in Orchard

    One of the pain point faced by lot of developers/bloggers migrating to Orchard CMS platform is the process of enabling the search feature. In Orchard the search feature is disabled by default. So even if the search box is visible in the site, when you try to search the site/blog contents, it will return an error saying, "Please define a default search index". If you this error, then you can confirm that the it's not enabled and if you gets error message like "No results found" even if there exists content for the search criteria, you can confirm that the search is enabled, but index is not properly rebuilt after enabling the search.

    In this post, I am going to show you how to enable the search functionality and to make sure that the contents are listed while searching.

    To enable searching, you need to make sure that the following modules are enabled.

    1. Search - enables you to search the index using keywords on Lucene query syntax and returns list of matching items
    2. Index - creates an index on the items in the blog/site
    3. Lucene -Implements the searching by using the index we have created

    To enable it, go to Modules and search in the Filter box in the Features tab as shown below. If the module is installed then it will show there, otherwise you need to install it first. Clicking on the Enable link to make it available in the site.

    Categories: Orchard

  • 1
  • 2
  • 3
  • ...