Post

SharePoint 2010 deployment within Visual Studio

SharePoint 2010 comes with a great set of tools for development. The development process in previous versions of SharePoint was totally abandoned. Now we have project templates, project items, menu items and deployment configurations.

Moreover, MSDN has a really nice series of articles. The out-of-the-box deployment configurations are really cool: after the build of SharePoint project, Visual Studio will pack its content to SharePoint solution (wsp file), add it to solution store of SharePoint and instantly deploy, if there is already such solution installed, Visual Studio will retract and remove it prior deploying. Sounds good, however it has some drawback in certain scenarios:

  • You can deploy only to one web application
  • Retracting and deploying doesn’t happen magically fast, especially when the machine is virtual and has no more than required hardware configurations
  • Recycling step can be configured per project, so its either on or off and, again, only one web application can be recycled
  • No way of coping files to virtual directories of all web applications. For instance, compat.browser or robots.txt or sometimes even web.config. Actually, its a drawback of SharePoint’s solution framework.

Some real life scenarios:

  • I have many files inside some mapped folder and number of features in the same project. I changed only one css/aspx/ascx/ashx file. I want that only that file will be copied and no recycling done.
  • Same project. I changed elements/schema.xml/ghostable file inside feature. Again, I need only this file to be copied, I don’t want all features to be reinstalled, however I do want all pools recycled.
  • Somebody do checkin in source control of  compat.browser file (lets say he added control adapter). I want via same deploy method to copy that file into App_Browsers folder of every web application

Well, there are really more examples, but I was annoyed mostly by those.

Long story short, I wrote an extension for Visual Studio, which adds new Deployment Configuration. The main difference is that those steps won’t deploy SharePoint solution, but perform a copy of only modified file to correct places on your machine’s file system:

  • Mapped folders files will go to HIVE
  • Features files will go to FEATURES folder
  • AppGlobalResources will go to virtual directory of every web application (just like it do SharePoint solution)
  • The assembly will go to GAC
  • There is special trick for other than resx files in virtual directories

I do pool recycling manually - I have a shortcut to PowerShell script pinned to taskbar, so its really only one click.

Sure, using this won’t install or activate newly added features. This extension is missing few things that I plan to add in the near feature:

  • Safe controls entries adding. Meantime, the only options are either to add them manually or deploy at least once the solution.
  • Additional assemblies in package are not copied to GAC
  • Retraction process

The extensions can be downloaded from Visual Studio Gallery.