Posts

Showing posts from November, 2018

Maintaining AssemblyInfo for multiple projects

Image
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:

‍<Project>
  <PropertyGroup>
    <Version>1.1.0</Ve…

Use Visual Studio extension to distribute your Code Snippets

Image
Introduction In a previous post we saw how you can build code snippets to write tests faster empowering your team to follow good practices. https://www.albertocorrales.com/2018/10/writing-unit-tests-faster.html

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

Image
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…