Showing posts from 2018

Script to clean your Visual Studio solution folder

Sometimes, cleaning your solution folder comes in handy when you want to build from scratch. If you don't do so, you can have unexpected results because of the files generated by your previous builds.

To carried out the cleaning task, I use a simple script which allows me to configure a list of folders I want to remove. This script is divided in two parts. The first part is just a script to check if we have admin permissions. If not, it will display a pop-up to get admin permissions.

You can skip this part, but it is very handy, since the cleaning part might need admin permissions. This part can be very useful for all your scripts, which need admin permissions.

:: BatchGotAdmin :------------------------------------- REM  --> Check for permissions     IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" ( >nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system" ) ELSE ( >nul 2>&1 "%SYSTEMROOT%\system…

Why you should migrate your old csproj to SDK format

Introduction  With the introduction of Visual Studio 2017, the format used for csproj was updated including several advantages. This new format will be used when you create a new .Net Core project or .Net Standard library. In spite of the fact that VS2017 continues supporting old csproj format, you can migrate your old projects to SDK format. As a result, you will have the following benefits:

Cleaner csproj files. With new format, a lot of things can be omitted, so your csproj files will be cleaner. Files are included using a wildcard, instead of including every single file. Solution project references are simplier.NuGet reference packages as PackageReferences, so you won't need packages.config and you will be able to use wildcard in your references (for example, 1.0.*).NuGet package definition as a part of the project file. You won't need more nuspec files.Definition of AssemblyInfo attributes in csproj, you won't need more AssemblyInfo.cs files. In addition, you will be…

Maintaining AssemblyInfo for multiple projects

When you are developing an application or manly a NuGet package, you might want to keep the same AssemblyInfo for all your packages, which involves updating each project when you want to publish a new version of your package according to the SemVer convention Semantic Versioning 2.0.0 | Semantic Versioning.

In order to make it easier, with the improvements of dotnet core and the new csproj syntax, which I strongly recommend, MSBuild 15 introduced a pretty cool feature: Solution-wide project properties with Directory.Build.props Customize your build - Visual Studio | Microsoft Docs. Basically, this allows you to define certain properties and use them in all your project in a centralised way, so you don't have to update your projects one by one.

All you have to do is create a new text file named Directory.Build.props and place it where you have your solution file. Here is an example of the properties you can use:


Use Visual Studio extension to distribute your Code Snippets

Introduction In a previous post we saw how you can build code snippets to write tests faster empowering your team to follow good practices.

In this post, we will see how we can distribute our snippets with a Visual Studio extension, which offers different advantages, for example:
You encapsulate your snippets in a VS extension, you you don't need to distribute them independently, and developers don't need to add them to VS one by one. The extension can be updated improving he current snippets or including new snippets.You can add more functionality in your Visual Studio extension.  Creating a new Visual Studio extension First of all, if you have never developed a Visual Studio extension, you might need to install Visual Studio extension development kit. To do it, install this option in your Visual Studio Installer

Create a new Visual Studio extensions project. For this example, I will name it "Snippets…

[Tip] Run Visual Studio as Administrator

Probably you already knew this trick to run apps in Windows 10 as Administrator. If not, I hope this tip can help you.

Sometimes, you need to execute Visual Studio as Administrator always, for example if you are deploying and debugging your application in your Local IIS. To execute VS as Admin there are several ways.

1) Using Sub-menus:
If you go to the item in Windows menu and click on right, you will see menu "More", where you can run VS as administrator.

2) Using shortcuts:
Previous method is slow, so If you don't want to do this each time you open VS, you can create a shortcut in your Desktop and execute it as Administrator. To do this, press right click on the shortcut, click on Advanced and select Run as administrator.

3) Always as Administrator:
Method 2 is much better than 1, but you always have to open VS by using your modified shortcut. So for example, you can not open directly a file .sln with Admin rights. But don't worry, there is a method to execute VS alw…

Writing unit tests faster

Introduction When you are writing tests, the name of the test is very important because the person who is executing the test should be able to detect what was fine or wrong at a glance. For this reason, it is a good practice to follow the convention format:
TestedMethodName_InputData_ExpectedResult By using this format, we can see in a line the method to test, the input used and the result expected, so it will be easy to identify what was wrong.

Another good practice is following the "Arrange", "Act", "Assert" convention (, so when we are reading a test, we can identify easily each part of the test. To make more visible each part, unit test usually include one comment per each state of the test.

Finally, if you are using different test categories, for example to classify unit tests and integration tests, you should use the word TestCategory("YourCategory") in your metadata definition.

Using the snippet In ord…

Debugging faster in Local IIS with Visual Studio

When we deploy in our local IIS, we have to attach to the IIS process in order to debug the source code from Visual Studio.  In order to do that, we open menu Deblug>Attach to Process, and we find the IIS process, which is called w3wp and we select all the corresponding IIS processes.  This method is time consuming, but using the extension Attach to All The Things we can carry out this task faster. In order to install the extension, we open the menu Tools>Extensions and Updates, and we search the extension "Attach To All The Things".
After installing this extension, we can see a new option in Tools menu with the title "Attach to IIS".
With this menu we can do the attaching task only with two clicks. However, as this is a feature that you will use very often, you might want to have it in your main toolbar instead of using the menu Tools. In order to make a shortcut in your toolbar, you can add a new customized button with the following menu.
In Customize wind…

Use tabs in windows explorer with QTTabBar

QTTabBar is the first application that I install when I format my computer, since it allows me to work better with Windows Explorer. Basically, QTTabBar will change windows explorer in order to use tabs, as if you were using Chrome.

This comes in handy when you are working with multiple folders, as for example several shared folders, local directories, etc. Apart from using tabs, QTTabBar has a lot of options to be customized.

By clicking on right button over the toolbar you can access to the options menu:

In tab "Tab" you can customise the behaviour of the events. For example, this is the configuration that I use:

QTTabBar also add some extra behaviour, for example if you double click on an empty space in a folder, it will go up one level. This options can be changed in "Window" tab:

Additionally, there are other useful features such as merge windows into tabs. If you have several instances of windows explorer, you can merge then into one window with several tabs…

Multi-language single page applications

Introduction When we are developing applications, one of the challenges is to manage several languages. In particular, I am dealing with this matter in a personal project, which is being developed using vue.js. (, so this post is focused on vue.js, but it could be used by other technologies.

In order to maintain your language translations, several aspects are desirable:

Easy to use. For example, if I am writing html, one tag or class should be enough to say that I want to translate a given literal.Easy to maintain. When we are writing code, we don't want to care about translations or sometimes even we are not allowed to choose a particular, maybe because it is a decision of a different department or a professional translator.Available for multiple coding languages. For example, if we are developing with vue.js, we should consider html, javascript or vue files. If we migrate our application to a different technology (like Angular), our translations should work wi…

Install an SQLite database in your Xamarin app

Introduction When we are developing a Xamarin application, one of the important points may be the initialization of the data for our application. To carry this out, there are different options:

Download the data when opening the application for the first timeSave the data in JSON or XML filesPreload a SQLite database
In one of my personal projects I had this situation. In the beginning, we had implemented the first option, load the data when organizing the application. The problem with this approach, the data loading can be quite time consuming and the user experience the first time the application is opened can be quite negative. In the measurements it took at the last hour.
With respect to the second option, load the data of a JSON, it solves the issue of the issue of the heavy load time, and that the JSON is installed as a resource next to the application. The downside of this is that it is not a highly optimized format when making queries and also the size of our APK or IPA will c…

Improvement in the Test Explorer for Visual Studio v15.7

The next Visual Studio update (v15.7) will include an improvement in the Visual Studio Test Explorer that will allow us to see the best organized tests. So far we are seeing them like this:

And with the improvement we can see them organized in a hierarchical way, grouped by project, namespace, class and method. This will also facilitate the execution of a set of specific tests (for example if we only want to launch those of a specific class). This is how the explorer test will look in future versions:

Although in Visual Studio the test categories already existed (, it is good news that by default we are grouped together in a much more practical way.

This information is based on the article and since it is not a version in production, you might experience some changes.

Happy coding!!

Publicando una aplicación .Net Framework en Azure con Docker y ServiceFrabric

Docker es una de las herramientas más potentes con la que puedes llegar a hacer cosas alucinantes y que me enamoró desde el primer día que oí hablar de ella. Aunque su principal target son las arquitecturas de microservicios (principalmente en linux), las arquitecturas monolíticas también se pueden aprovechar mucho de la potencia de Docker, ya que Docker nos ofrece la posibilidad de tener nuestra aplicación dentro de un contenedor que nos permitirá distribuirla de forma sencilla sin la incertidumbre de las condiciones de cada entorno concreto. Es decir, se acabó el oír la típica frase de "en mi local funciona".

En el proyecto que me encuentro trabajando, aunque se hace uso de diferentes servicios, la parte web se compone de una arquitectura monolítica de N-capas con .Net Framework en el backend y Angular5 en el frontend. En un  plazo medio-corto uno de los objetivos es migrar esta arquitectura a Azure con SaaS y si se puede, aprovechado todas las ventajas que n…