In everyday Sharepoint development we often need to create many console utilities for various maintenance tasks which should be performed on production or staging environments (e.g. install bugfix on living Sharepoint site, trace some information from production site, etc). Before to run program on remote server we test it on our development environment and then copy it to remote server and run it there with different site URL (in most cases there are different URLs on production and dev environment). So we have to write the following code each time we need to create such utility:
It is very annoying. So I created ReSharper live template which slightly simplify this task. Just add the following code to User Template (in Visual Studio menu ReSharper > Live Templates > User Templates > New Template):
and specify “Shortcut” for it (e.g. “spsite”). Now you are able to create the above code by typing “spsite”. ReSharper will offer spsite template for you (like it does for “for” or “foreach” templates):
After selecting of “spsite” template ReSharper will add this code for you and it will allow to specify parameters in SPSite() constructor and OpenWeb() method by clicking Enter key (which is more convenient in comparison with VS code snippets):
This is a little automation which slightly simplifies creation of console utilities for Sharepoint.