Build and Publish NuGet Package in Azure

Most of the time we would like to have our common library used by many applications. Integrating the library as a part of all the solutions is not ideal when the requirement is to have the common implementation used in various projects. NuGet helps us to create a separate package that can be used globally which serves the purpose of implementing the common functionality across all major solutions. Thinking on those lines, today I would like to share the idea of how we can achieve of building and publishing a library as a NuGet package using VSTS in Azure.

In one of my post I have already discussed about how we can create a NuGet repository in Azure. Lets have a look into a step-by-step process of how we can create a NuGet feed in Azure and publish the NuGet package for the library so that it is available in the feed.

Step 1: Create a NuGet Feed

VSO can be used to host a private NuGet feed and in order to do that first you need to install Package Management to VSO. It provides an extension that enables continuous delivery mechanism by hosting packages which will be available for consumption and usage by team, builds and releases. Once installed you can see a Package link against each Team project in your Team Services dashboard. If you already have the Package link, then don’t bother to install it again.

Once you have installed the Package Manager in VSO, you can then create a Feed using New feed which includes a Feed name and description for the feed.

Once done your feed is ready to upload packages.  You can also add the required permissions for those who you would like to authorize to upload packages into the feed.

Step 2: Create NuGet Packages of your Library

Once you are good with the feed, it is time for you to generate NuGet package for your library and publish it in your private hosted feed. In order to do that, add a NuGet project in your solution which contains the Library project.

Typically the structure would look like this which will also include the nuspec file for the library that you would like to create the package for.

Open the nuspec file and update the id, version, title, etc. along with project Uri of your NuGet repository. That Uri is not mandatory but it is better to keep it. Add the release path of the DLL and PDB file of the class library project whose package we want to create.

You can create more than one nuspec file which can be specific and related to multiple class library projects in your solution that can generate multiple NuGet packages to be hosted in NuGet repository. However it depends on your requirement.

Open the NuGet.config file and add the api key and package source for the NuGet package explorer. Again its not mandatory to do that as we are trying to automate the NuGet package development using VSO team service but for future reference purpose you can keep it.

That’s all you need to do. One more thing that you might have to do is open the NuGet project file in notepad or notepad++ and verify the settings of AfterBuild are same as below.

Step 3: Prepare your Build definition in Visual Studio Team Services

Select the team project in VSO which contains the library project and solution. Select the Build section and add a new Build definition for your library.

Select the build definition template Visual Studio.

While creating the Build definition, you would be prompted to select Continuous Integration (CI) build which means whenever you check in the code to source control, immediately this build will be triggered. It is a best option to do that when you have a requirement to create and deploy the NuGet package as soon as you check in your code to source control.

Once the Build definition is created for the team project, you will see the sequential order of how the build will happen through VSO. The steps involved are:

  1. Restore the NuGet version
  2. Build the Solution
  3. Test the Assemblies and execute the Test projects
  4. Publish the files and index the source code
  5. Copy the published files to artifacts staging directory
  6. Publish the artifacts and drop it to the server.

What we need to include is another step to to publish the NuGet package to the private hosted NuGet feed as soon as the solution build is complete which means in between Step 2 and 3.

In order to do that we need to add a build step of publishing the NuGet package to the feed. Select Add Tasks and add NuGet Publisher from all the listed tasks available.

Once added, drag the NuGet Publisher just after the Build Solution step so that once the project is successfully build, it will publish the generated NuGet.

Once done, lets review the following definitions Build, Repository, Variables and Triggers.

Build Definition Tab

Select Feed Type as Internal Feed and add the Internal Feed Url that we have created in our Step 1 in our NuGet publisher build step.

Repository Tab

Verify the mapping information of the server path to the source location of the project of Team explorer is correct. This can be validated in Repository tab of Build definition.

Variables Tab

Add a variable which will represent the API key to access the NuGet feed and authorize the user to upload the package. This is important as we don’t want any unauthorized user to upload anything to the private feed.

Trigger Build

Verify that CI build include the repository path of the solution from where the NuGet packages are going to get created.

That’s all and we are done. Its is time to validate and trigger a build to check if everything is working as per expectations.

Click on Queue build…. and verify how things are going.

Hope that this will help my fellow developers to Create and publish NuGet packages in Azure.

Unable to expand or display column nodes of SQL Azure database connected in SQL Server Management Studio 2014

Sometimes when you are working on a SQL Azure database using SQL Server Management Studio, you might encounter a strange issue of not able to expand the tables to list down the column nodes or display the column nodes. I am using SQL Server 2014 and I had been facing this issue for a long time.

The error might say any of the following:

Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc) For help, click:

unknown property IsMemoryOptimized (Microsoft.SqlServer.Management.Sdk.Sfc) For help, click:

Finally I was able to solve this issue by updating my SQL Server 2014 with Service Pack 1 downloaded from the following link

Hope this will provide a resolution for someone who is encountering the same issue.

Generate SQL Azure DB Schema Diagram

There was a necessity for me to generate a Schema diagram having all the DB objects for my SQL Azure database. Unfortunately while you connect to your SQL Azure database through SQL Management Studio, you will not find the option to generate DB diagram like the one you get from by connecting to Local SQL Server Database

In order to accomplish that I had downloaded SQL data Migration Wizard from and did a migration from SQL Azure too Local SQL database. I did find another tool in order to generate Schema diagrams DBForge Studio for SQL Server but you need to pay for this. You can also generate the schema diagram using Entity Framework through Visual Studio but I don’t want to take that path.

Step by step I went ahead using the Migration tool to generate SQL objects from SQL Azure to my local database. Also this tool is really helpful when you want to migrate the schema object from local database to SQL Azure.

My first step is to run SQLAzureMW (Migration Tool) that I had downloaded from the above link. I had selected the Migrate option and also Target Server as my Local SQL Server.


Next step is to connect to the source whose schema migration is required.


Next step is to select the object or objects whose schema is required for migration purpose.


The next screen will show the summary and along with that the SQL Script creation required for migration purpose will be started.


Once the SQL Script generation is complete you can either save the script for your pre deployment steps or you can continue with next level of migration.


While you click Next, you will get the window where you need to select the target SQL Server which might be a your local SQL server or another SQL Azure Database. Since I need to create my database schema diagram, I went on selection for my local SQL Server and my database where I need to migrate the SQL Azure table objects


The above step will execute the SQL Scripts generated from SQL Azure database against my local SQL server database.

All good to go. My database have all the tables I wanted and I am ready to generate database diagram. Godspeed…

Awesome tool to play with your code

I came across this tool called and I can say that is simply awesome. There was a requirement for me to convert XML to JSON and vice versa and came across this tool and I would say it just made my life simpler. Even you can play with nodes of JSON by adding, removing the nodes specific to your test or requirement. This is handy especially if you are trying to Mock objects or HTTP response in JSON format. Try it as it gives you more than just what you need for your programming.




Database Project build fails in Visual Studio 2013

Recently I had experienced a strange issue while building a database project in Visual Studio 2013. Most of the times we require a database project so that we can manipulate the queries and DB objects through Visual Studio. Hence we go for a database project by selecting the available project template as shown below.


Once you have selected the project, you would like to build the project. And suddenly you might encounter issues like below.


No worries. There is a resolution for that too.

Microsoft provide a repairing Data Tool which you can download from the following link Installing the tool should resolve the issue.

In case you still have the issue just go ahead and update SQL Server database using Extensions and Utilities from Tool menu of Visual Studio.


This has eventually resolved my issue after my system got restarted on completion of above installation process.

Hope it helps…..

Owin.IAppBuilder does not contain definition for UseWebApi

At some point of time you might had encountered issues with Owin.IAppBuilder giving error in Startup class which states

‘Owin.IAppBuilder’ does not contain a definition for ‘UseWebApi’ and no extension method ‘UseWebApi’ accepting a first argument of type ‘Owin.IAppBuilder’ could be found (are you missing a using directive or an assembly reference?)

This basically happens when try to add route configuration to the OWIN pipeline while using ASP.NET Web API2 OWIN. You might try updating the OWIN package from to using the NuGet command update-package Microsoft.Owin but that will not resolve the issue.

Solution is you need to install Microsoft ASP.NET Web API2 OWIN Self Host which will resolve the issue. You can use the NuGet command Install-Package Microsoft.AspNet.WebApi.OwinSelfHost


Publishing NuGet Package using NuGet Packager Extension

In one of my last post I have explained how we can create a NuGet Package on every build and deploy it to NuGet server in Azure.

In this post I would like to emphasize on how we can use the NuGet Package Extension in Visual Studio and publish NuGet packages to the server.

First of all we need to install the extension from the following url Once you have installed the extension for Visual Studio you can get the project template to create NuGet Package as shown below.


Once you add the NuGet Packager project to your solution, you can find the project hierarchy as shown below.


Now all you need to do is configure the NuGet project in order to take the libraries that you would like to publish. Open the NuGet.config file and provide the server url where the package is going to get published. Add the ApiKey which will validate the publishing of the library.


Copy your libraries that you would like to publish in the lib folder of the NuGet project.


Rename package.nuspec file to a name that you would like to distinguish for and update the project url in the nuspec file pointing to the publishing server


Change the description and other parameters as you want. You can even provide the dependencies to get installed or validate during the installation of the package

Now all we need to do is build the Package project. You might encounter some issues during building the package if you have renamed the nuspec file. Open NuGetPackage.ps1 file and change the following statements to point to correct NuSpec name


Build it again. Now you will not see any error. When you are building the NuGet project in Debug mode it will create the package *.nupkg file locally. In order to deploy it to the server through build process, you need to build it in Release mode.

Now if you go to the NuGet feed url of your server you can view the package over there.


You can even view through NuGet package manager the package installed.


If you want to delete the package from the server then you need to use the following command in Command Prompt.

nuget delete <Package Name> <Version> <API Key> –Source <NuGet Server Url>


That’s it you are good to go.