Team Project Rename

Renaming of Team Projects is one of the most requested feature on Visual Studio User Voice:


Figure 1: Team Project rename suggestion on User Voice

Today, Brian Harry announced new Visual Studio Online Update and it contains this feature, even if it will not be available to everyone at the beginning. For those people that uses TFS on-premise you will have this feature in the upcoming new version: TFS 2015.

I strongly suggests you to have a look at Visual Studio User Voice and give your suggestion, because it is in the radar of Visual Studio Team.

Gian Maria.

Missing Developer Command prompt for Visual Studio 2013

If you installed Visual Studio 2013 but you are not able to find the “developer command prompt” in your Windows 8 environment, the solution is simple. Just go to the folder

“C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts”

Now right click on Developer Command Prompt for VS2013 and choose “pin to start” and the game is done.


Gian Maria.

Removing Network Emulation of Visual Studio Test Runner

Visual Studio has the ability to simulate network speeds during test execution. This feature is nice especially for Load Test, because it permits to really simulate users that have different configuration speed. This ability is granted from a network component that gots installed in your TCP/IP stack and one of the question that usually arise is

I’ve enabled it in my machine, but now I want to remove because I’ve installed only to try to run a load test.

The solution is opening an Administrator Developer Command Prompt and issue the command vstestconfig NetworkEmulation /Uninstall

C:\WINDOWS\system32>vstestconfig NetworkEmulation /Uninstall
 Microsoft (R) VSTestConfig Version
for Microsoft Visual Studio v11.0
 Copyright (c) Microsoft Corporation.  All rights reserved.

Network Emulation Configuration:
                Removed network emulation driver successfully.

This will remove completely the emulation Driver. The same command has an /Install option to install it again if you want to run Web Performance test simulating different network speed as well as a /Repair option useful if the component is installed, but Visual Studio complains that he is not able to use it.

Gian Maria.

Manage Test Data in Visual Studio Database project

One of the greatest missing of Visual Studio Database Projects, is the ability to manage data in a Database Project. One widely used technique to overcome this limitation is using PostDeployment scripts and script data inserting. This technique is used also to insert test data inside the database. When used in this way, you need some way to avoid inserting test data in Production Database, so you need to find a technique that permits you to run the inserting test data only when needed.

A first solution can be: differentiate post deployment scripts based on active configuration, basically one of the Script runs when the configuration is debug and the other one should run when the configuration is release (or other).

Actually Database Projects does not distinguish between various configurations so you need to resort to some hack to have it works. Basically you create one script for every configuration you want to use.


Figure 1: Create one script for every configuration you want to support

Then you need to unload the database project, edit the project file directly and add a pre-build step that basically copy the right script over the Script.PostDeployment.sql based on the active configuration

  <Target Name="BeforeBuild">
      DestinationFiles="Scripts\Post-Deployment\Script.PostDeployment.sql" />

This is not a so good hack, because every time you change the configuration the Script.PostDeployment.Sql will be overwritten and marked as changed. In this situation you should remember avoiding to check-in to avoid too much noise in the source control. Modifying source file with a pre-build action can also lead to TFS Build failures, because the Build agent uses standard Server workspaces and all source files are in read-only mode during the build. Moreover there is too much risk that someone mistakenly runs the debug version against production database and you will have test data inserted into production DB, so this is not my choice.

A better solution is leaving your Database Project post deployment script free from test data, use them to only insert the real configurations, but create another Database Project. This new project references the original Database Project and contains post build script to generate test data. This technique keeps your original Project clean, when it is time to deploy test data, simply deploy the other database project and thanks to the reference all the original schema will be deployed, then the post deployment script of the other project will insert Test Data.


Figure 2: Create a specific database project to deploy test data

Now the only interesting part is how to create the InsertBaseData.sql script to insert some base test data and make it stable. If you create a script with a long series of INSERT INTO, you will probably fill database with unnecessary data, or worst, the script may fail due to unique index validation.

Everything you need to know is in this interesting article from Sql Server Central called Generate MERGE Statements with Table Data. In that article the author shows you a nice stored procedure used to generate a series of MERGE statements from a database with real data.


MERGE INTO [Categories] AS Target

  ('model','Model Airplanes')
 ,('paper','Paper Airplanes')

) AS Source ([Code],[Title])
ON (Target.[Code] = Source.[Code])
 [Title] = Source.[Title]

This is really useful because you can simply fill a real database with test data and when you are happy with it, generate the script that will recreate the same sets of data.

Thanks to this simple technique you can manage Structure and production data in main Database Project and having other Database Projects to generate test data to automatically setup Test Environments.

Gian Maria.

Converting a Visual Studio plugin from 2012 to 2013

I’ve some little utilities for Visual Studio, born as a Macro and then converted to Plugin. Now that VS 2013 preview is out, I want to convert that addin to support the new version of Visual Studio, so I can use my utilities even in VS 2013.

The whole conversion process is really straightforward, first of all I create a branch of the original VS2012 version of the plugin, just to be able to compile again with VS 2012. This is nothing more than having a backup of the project.


Figure 1: 2013 version is just a branch of the 2012 version

Now if you open project file with VS 2013 it will ask to convert the project, just choose yes and you are done, the project is converted for VS 2013. Unfortunately if you compile the project and try to install the .vsix file you will find that it does not install on VS 2013. You should simply edit the source.extension.vsixmanifest file telling that the addin supports newer version of VS


Figure 2: Choose supported version of VS where this addin can be installed

Now you can simple uninstall the old version from your VS 2012 version and simply install the new version, that now supports from VS 2010 to VS2013. If if double click the vsix file I can install the addin on all installed and supported versions.


Figure 3: Your converted addin now support both 2012 and 2013 preview

Working with Visual Studio SDK is really simple, and the upgrade procedure is a further confirmation of this fact. You can simply open the addin with the new Visual Studio Version, change supported version list and your addin is ready to be used in the new version.

Gian Maria.