Sunday, July 31, 2016

Hello World - Your First Extension to .NET Visual Studio 2015 - Open Source


Visual Studio Extension - Hello World

Sometime back  I have participated in 3 days session  called .NETUNBOXED  event where I got a chance to meet with many giants of Open Source platform, Including Microsoft's Project Manager for Open Source team. I learned a lot from them, and thought of writing small hello word program to start on this series. 

So, Let's see how to write your first extension for Visual Studio 2015.

You can use any version of visual studio to write your own extensions except Express


System Requirements 

1. Visual Studio 2015 (Community / Professional / Enterprise)
2. Visual Studio Development Kit

There are three ways to install Visual Studio Development Kit. 

A. Installing VS SDK (Visual Studio SDK) during Visual Studio Installation. 
B. Installing VS SDK after installing Visual Studio. 
C.  Installing VS SDK during project creation. ( This is what I used for my First Application)


A. Installing Visual Studio and Visual Studio Development Kit together

1. Visual Studio 2015 : Any Visual Studio version except express, can be use if available, if not, your can download free Visual Studio 2015 Community version from the following link 


Choose 'Community' 

2. Make sure you click on 'Visual Studio Extensibility tool' under 'custom tool' to install Microsoft SDK 
(Software Development Kit)

VSSDKInstall


2. Visual Studio Microsoft Development Kit : 

B. Installing Visual Studio Development Kit after Installing Visual Studio

When you already have Visual Studio installed on your system, you need only Microsoft Software Development Kit to write your own extension for Visual Studio. 

1. Click on Control Panel - Programs - Programs and Features - Visual Studio 2015 - Change -



2. You will get following screen.  From Select feature, Click on Common Tools - Visual Studio                    Extensibility tool update 1 (Same as shown in earlier step)

C. Installing VS SDK during project creation.

1. Open Visual Studio 2015 - File - New - Project 
2. From Install - Template - Choose Extensibility 


3. If you don't have VSSDK, Visual studio will prompt you to install it. 




4. You will get prompted for 'Install Missing Feature' Click on 'Install''



5. You will see a screen to update 'Visual Studio Community 2015', Click on Update. 




5. You will see a following screen as a part of smooth installation. 




6. After Few Ok's following screen will get to where you see by default - ' Visual Studio Extensibility Update 3'  is already selected for you. Click on 'Next'





 Hello World 


You are ready to write your first Hello World Extension in Visual Studio. 

1. Open Visual Studio 2015 Community. 

2. Click on File - New Project - Templates - Visual C#

3. Click on Extensibility to write your first Visual Studio Extention. 

4. Choose 'VSIX Project' it stands for  'Visual Studio Installer for Extentions' 

5. Name project ' HelloWorld' 

6. Click on 'OK'



7. Right Click on the Project - Add - User Control 


8. Go Back to Extensibility - Custom Command
9. Name it as 'HelloWorldCommand' and click on 'Add'





10. You will see following screen, which shows command is getting added to the project.



11. You can see bunch of files related to Command


12. Click on 'HelloWorldCommandPackage.vsct'

13. Add 'Hello Wrold' Between 'ButtonText'
       
     

14. Open 'HelloWorldCommand.cs'

15. In 'MenuItemCallback' event replace existing code with following snippet.

            private void MenuItemCallback(object sender, EventArgs e)
            {
                        string message = "Hello World";
                        string title = "My First Visual Studio 2015 Extention"; 

16. Build And Run

Where your extension will be ?


17. When you build and run, New Visual Studio Experiment instance will be open.

18  Click on ' Tools' and you will see your first ever Visual Studio Extention in Visual Studio 2015.



19. You Will see following screen in Visual Studio Experiment instance



20 My First Visual Studio Extension - Hello World. 




These are the steps to write your First ever Visual Studio 2015 Extension.


Wednesday, March 16, 2016

Hello World - NServiceBus

It was sunny afternoon in October and Jimmy Bogard who is Chief Architect was right in front of us explaining  'How NServiceBus works'. 

Communication is backbone of IT industry and Service Bus is it's nerve system. Though it is relatively new, going further, Service Bus will be important factor in IT industry which will change entire communication architecture

NServicebus is a open source and can be downloaded from http://particular.net/downloads. (Detailed steps are provided below)

NServiceBus has following inbuilt capabilities -

  • Async Messaging
  • Windows Failover Cluster
  • Performance Counter
  • Detailed Performance Data 
  • Custom Checks 

What you will learn at the end of this blog -
  • How to Write Hello World NServiceBus
Prerequisite
  • NServiceBus Nuget Package 
NServiceBus Nuget Package
  1. 1. Download NServieBus open source from http://particular.net/downloads
2. You will get following screen which says

    To install NServiceBus core libraries from Nuget, open the Package Manager Console and type

              :

3. Getting Nuget Libraries in Visual Studio Project 
  • Open Visual Studio 2015
  • Click on File -> New -> Project 
  • Click on Installed -> Templates -> Windows 
  • Select Project of type Class Library 
  • Provide Name - Hello World
  • Location to store the project , In this example I have taken 'C:\Blogs\NServiceBus'
  • Keep remaining options as it is. 
                             
  • You will get following screen
                         

Now we need to add NServiceBus.Host and NServiceBus.RavenDB Nuget references in our projects

  • Right click on References ->  Manage Nuget Packages 
  • You will get following screen, follow steps mentioned in the scree for both references. 


  • You can see 'EndpointConfig.cs' is already added in the project.
  • Change original program as shown below.  
      namespace HelloWorld
      {
        using NServiceBus;
        using NServiceBus.Logging;
        using NServiceBus.Persistence;
        public class EndpointConfig : IConfigureThisEndpoint, AsA_Client,               
                                      IWantToRunWhenBusStartsAndStops
        {
           public void Customize(BusConfiguration configuration)
           {
            configuration.UsePersistence<RavenDBPersistence>();
           }
           public void Start()
           {
            LogManager.GetLogger("EndpointConfig").Info("Hello Distributed World!");
           }
           public void Stop()
           {

           }
       }
      }
  • Click on F5
  • You will see following screen 
  • You have finished your first program 'Hello World' for NServiceBus