[null, null, {"document_url": "http://www.albertocorrales.com/2018/11/visual-studio-extension-to-distribute.html", "unformatted_src": "https://2.bp.blogspot.com/-Lfnybv_dJGU/W_HARGeQ7tI/AAAAAAAAFBA/zXKR8RKw9HQfJ2sVSfkblt8dlE9z3yTxgCLcBGAs/s640/2.JPG", "src": "https://2.bp.blogspot.com/-Lfnybv_dJGU/W_HARGeQ7tI/AAAAAAAAFBA/zXKR8RKw9HQfJ2sVSfkblt8dlE9z3yTxgCLcBGAs/s640/2.JPG", "rendered_width": 640, "rendered_height": 443}, null, null, {"document_url": "http://www.albertocorrales.com/2018/11/visual-studio-extension-to-distribute.html", "unformatted_src": "https://1.bp.blogspot.com/-mVlSFJj2dk0/W_HARk7xOfI/AAAAAAAAFBE/cnLIUE4WtOgaNnx2zjpODOJzWTscTYapwCLcBGAs/s320/4.JPG", "src": "https://1.bp.blogspot.com/-mVlSFJj2dk0/W_HARk7xOfI/AAAAAAAAFBE/cnLIUE4WtOgaNnx2zjpODOJzWTscTYapwCLcBGAs/s320/4.JPG", "rendered_width": 320, "rendered_height": 250}, null, {"document_url": "http://www.albertocorrales.com/2018/11/visual-studio-extension-to-distribute.html", "unformatted_src": "https://3.bp.blogspot.com/-F5uND6G_rKM/W_HASFOQHEI/AAAAAAAAFBI/5LxY2cI1HsYNtbJ2GQQoOf_paoT79WBRgCLcBGAs/s1600/5.JPG", "src": "https://3.bp.blogspot.com/-F5uND6G_rKM/W_HASFOQHEI/AAAAAAAAFBI/5LxY2cI1HsYNtbJ2GQQoOf_paoT79WBRgCLcBGAs/s1600/5.JPG"}, null, {"document_url": "http://www.albertocorrales.com/2018/11/visual-studio-extension-to-distribute.html", "unformatted_src": "https://1.bp.blogspot.com/-zsdVficzu6Y/W_HASVf8sPI/AAAAAAAAFBM/x7WhnWFWtb8ugxWIn6M-GVcGQTq-JKifwCLcBGAs/s1600/6.JPG", "src": "https://1.bp.blogspot.com/-zsdVficzu6Y/W_HASVf8sPI/AAAAAAAAFBM/x7WhnWFWtb8ugxWIn6M-GVcGQTq-JKifwCLcBGAs/s1600/6.JPG"}, null, null, null, null, null, null, {"document_url": "http://www.albertocorrales.com/2018/11/visual-studio-extension-to-distribute.html", "unformatted_src": "http://3.bp.blogspot.com/-nmUEkNXdwxs/W99ZJC9hJ4I/AAAAAAAAE9s/bLdiy4Wu0DMMnvdLZroKUDsX4mYWWBlCgCK4BGAYYCw/s311/51gP9mXEqWL._SX379_BO1%252C204%252C203%252C200_.jpg", "src": "http://3.bp.blogspot.com/-nmUEkNXdwxs/W99ZJC9hJ4I/AAAAAAAAE9s/bLdiy4Wu0DMMnvdLZroKUDsX4mYWWBlCgCK4BGAYYCw/s311/51gP9mXEqWL._SX379_BO1%252C204%252C203%252C200_.jpg", "formatted_filename": "gP mXEqWL", "alt_text": "Currently reading", "rendered_width": 237, "rendered_height": 311}, null, null, null, null, null, null, null]

Use Visual Studio extension to distribute your Code Snippets

November 18, 2018


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:

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 "SnippetsExtension": In the root of the project, create a new folder named "snippets". Here you can store all the snippets you wan to distribute with your Visual Studio Extension. For this example, we will used the unittest.snippet example that we saw in the previous post. You can download it here: https://github.com/albertocorrales/unittestsnippet/blob/master/unittest.snippet.

For file unittest.snippet, it is important to select the following properties: In folder snippets, we will create a new text file and we will name it snippets.pkgdef. This file is used to add certain keys to the registry. As for this example, we are using CSharp, write the following:
// Csharp


For file snippets.pkgdef select the following properties:

If you followed the previos steps, you should see something like this: Now add your package definition in your VSIX manifest. To do it, double click on source.extensionvsxmanifest. Go to tab "Assets", and then, select the following options to distribute your snippets with your extension: Finally, test your extension. If you press F5, an experimental instance of Visual Studio will raise, the changes you make in this instance will not affect your development environment. To test your extension is working fine, create a new test project and type "utest" to see the new snippet you added. You can download this example from my GitHub repository. https://github.com/albertocorrales/SnippetsExtension

If you want more information about how to develop your own Visual Studio extensions, you can go here: https://docs.microsoft.com/en-us/visualstudio/extensibility/starting-to-develop-visual-studio-extensions?view=vs-2017

I hope you found this post useful,

Happy coding!
extensions testing unit tests Visual Studio VSIX



Multi-language single page applications

July 05, 2018 

Improvement in the Test Explorer for Visual Studio v15.7

April 09, 2018 

Happy coding!!

Install an SQLite database in your Xamarin app

April 17, 2018 Currently reading Designing Data-Intensive Applications

Favorite books
