C# Hello World on GitHub with Visual Studio 1


facebooktwittergoogle_pluslinkedinmail

Have you though about starting open source C# project but didn’t know how? Let me show you a GitHub kick starter.

Firstly, don’t be scared that it’s a long post – most of that are screenshots for your convenience. Next, about tools – I used Visual Studio 2015 Community Edition (free one).

 

Create GitHub repository

First you need to go to GitHub.com and sign up or sign in if you have an account already. Next click green ‘New repository’ button on the right side.

image

Fill in the form – enter ‘Repository name’ and check ‘Initialize this repository with a README’. Then click ‘Create repository’ button.

image

 

Install GitHub extension in Visual Studio

Once you have GitHub repository you can configure IDE. Open Visual Studio and navigate to ‘Tools/Extensions and Updates…

image

Select ‘Online’ in the left hand panel, type ‘GitHub’ in the search box in the right hand panel. Then select ‘GitHub Extension for Visual Studio’ and press ‘Download’.

image

Follow the installation (agree to license terms) and restart Visual Studio.

 

Clone GitHub repository locally from Visual Studio

It’s time to get the repo locally. So open Team Explorer (menu: View / Team Explorer) and click ‘Login’ in ‘GitHub’ section.

image

Type your credentials and click ‘Login’.

image

Click ‘Clone’ in Team Explorer.

image

Select repository, set target path and click ‘Clone’.

image

 

Create C# Hello World application

Finally some development work. When repository is cloned click ‘Create new project or solution’ hint in Team Explorer.

image

Choose ‘Console Application’, give it a name and press ‘OK’.

image

Type fancy code Smile

using System;

namespace MyFirstGitHubApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

 

Submit C# Hello World to local (cloned) git repository

Ok, you have your code ready. Now you need to push it to local git repo. So go to Team Explorer / Changes.

image

Setup your user name and e-mail address by clicking ‘Configure’ hint (first time only).

image

Fill in all the data, click ‘Update’ and then back button to return to your change.

image

Enter submission comment and click ‘Commit’.

image

Your change has been submitted to your local git repository – the one cloned from GitHub few steps above.

 

Push C# Hello World application to GitHub

The last step is to sync your local repository with GitHub. Click ‘Sync’ hint.

image

Next click ‘Push’ link next to your change in ‘Outgoing Commits’.

image

The change is in GitHub now! Congratulations!

image

You can check that GitHub is updated – my repo is here: https://github.com/csharp-today/GitHubHelloWorld

 

Summary

GitHub integration with Visual Studio is quite good. I personally see no obstacle to create open source C# code this way.

 

facebooktwittergoogle_pluslinkedinmail

Leave a comment

Your email address will not be published. Required fields are marked *

One thought on “C# Hello World on GitHub with Visual Studio