SharePoint: creating a calendar view on a Tasks list programmatically

Working with SharePoint, I've needed to create a calendar view on a Tasks list programmatically (i.e. from a feature).

I've done some research on the web, and I've found the great article Creating calendar view from tasks list programmatically.

From here you can see how to add a view and (very important) how to set the ViewData property of the view, but above all you can see the owssvr.dll service explained (even if you can use the more intuitive SharePoint Manager.

Only a note: from the initial link, you have to remove the "<Query>" enclosing tags from the query property.

What to do when creating a new wsp in a Visual Studio 2010 SharePoint 2010 solution

What to do when creating a new wsp in a Visual Studio 2010 SharePoint 2010 solution

Mandatory steps:

  1. delete the created snk and add a reference to your global snk file (add existing item, Add As Link)
  2. from project properties, sign the assembly using the previously referenced strong name key file
  3. from project properties, choose the deployment configuration between Default and No Activation
  4. from project properties, disable the Auto-retract after deploying flag
  5. if not done during creation time, from the project properties set the site url
  6. add the needed references to the other assemblies in the solution
  7. unload the project file and add the tag needed to create the wsp file automatically, as described in my post Visual Studio 2010: how automatically build wsp packages after SharePoint 2010 build
  8. from package, advanced, add the assemblies you want to include  in the wsp and deploy in GAC

Suggested steps:

  1. write one or more web-application scoped features, used to activate and deactivate the other features at site collection (SPSite) or site (SPWeb) scope
  2. if the wsp has not web-application scoped items, create an empy WebPart and a site collection scoped feature to be able to deploy the wsp to a single web-application, as described in my post SharePoint: how make your wsp deployable in a single web application