Intellisense support for NuPack in VS10.8.2010
Seeing the tweets around, by now most of you have already downloaded and tried out NuPack either by installing the library or creating your own NuPack package using the nuspec file. So, I’m gonna skip all the intro and jump straight to nuspec intellisense support inside Visual Studio. (will skip compiling nuspec to create the package also).
Every time you want to create a NuSpec file, you would open your favorite browser and navigate to the NuPack documentation and see the nuspec specifications. That could be a lot of hassle especially if you don’t have multi-monitor support and you have to press alt+tab. To solve this, I will show you some tips to work with Visual Studio.
Here is a sample screenshot when you open nuspec file in Visual Studio.
(Notice that there is also no syntax highlighting and intellisense support.)
There is a hidden feature in Visual Studio to map certain extensions to a particular editor. Since nuspec is an xml file, we need to tell VS to map it to the xml editor.
Open the Tools>Options menu.
- Make sure you select “Show all settings”.
- Then choose Text Editor> FileExtensions.
- Then add “nuspec” as Extension.
- Select Xml (Text) Editor with Encoding
- Click Add
- Click OK
- Restart Visual Studio
Now when you open a nuspec file in visual studio you will get syntax highlighting support same as with other xml files.
But you still don’t have any intellisense support.
There is a trick to get the intellisese in VS by using the xmlns and xsd combination.
First of all you need to get the xsd schema for nuspec at http://nupack.codeplex.com/documentation?title=Nuspec Format , save it as xsd and add that xsd to Visual Studio solution (Add Existing Item). (It can be referenced as solution item rather than a project item).
Now modify the <package> tag to add the xmlns attribute.
Select http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd as the xmlns. That is it. Now you have intellisense support for nuspec files.
I have also created an issue at codplex to add this support, you can view it at http://nupack.codeplex.com/workitem/207
Incase you want to download the xsd you might want to visit my FacebookSharp library project http://github.com/prabirshrestha/FacebookSharp/blob/nupack/src/nupack/nuspec.xsd(at the moment it is available in ‘nupack’ branch only. There is also a sample on using rake and albacore to create the package using ‘rake nupack’ – will work on an albacore task to create the package later on).
You can also use this same trick to support intellisense support in VS for your custom web.config section. You can check out my previous article Custom web.config Intellisense.
Like my VS theme? download it at http://blog.prabir.me/post/My-Visual-Studio-Theme.aspx
blog comments powered by Disqus