Starting to work with Visual Studio 2010 and its new project template for SharePoint 2010 development there is a couple of things that annoyed me.
To start off with, I do really like the way it behaves around packing, features, mapped folders, and other things.
One thing though that struck me right away was that it didn´t behave like a web application project…
OK, so in the box in 2007 (VS2008) we also had that problem with VSEWSS but then came a couple of great open source tools that overcome that problem like SPVisualDev that were based upon the web application project template. This enabled us to add things like .ascx, .aspx, and .master items to our projects and have them show up with code behind and designer files among other great stuff. The important thing was that it enabled us SharePoint devs to think more like asp.net developers do. The special SharePoint stuff like packaging of the WSP we left up to WSP Builder.
In 2010 there´s really not a need for WSP Builder any more as the built-in template solves this for us.
OK, going back to 2010 again…the project template again is not based on a web application project. (This probably has to do with the migration path from VSEWSS if I will guess).
What problems does this arise then?
When you click “add new item” and select the SharePoint 2010 tab you see (OOB) that we have User Controls and Application Pages but there is no Master Page available for us. (enabling CKS DEV extension “fixes” that issue for us but without the code behind and designer file).
If we then select the Web tab there is not anything useful we can use since the project template is not based on web application project.
This resulted in me adding a new web application project to the solution and I added a Master Page to that project instead and I finally copied that into my SharePoint project as you can see below.
What happened now was that I got no intellisense (that can be fixed thought) but now I wanted to work with a couple of SharePoint controls from the Microsoft.SharePoint.WebControls namespace.
Now there is two paths you can take.
Add a register tagprefix attribute to the top of each and every .ascx,/.aspx,/.master file that you are working with, like below.
Add this to the web.config file instead and have it all in one place (this might require you to update SharePoint with these changes but that´s not all that hard) instead. This is how we do it in asp.net
First of all, there is no web.config file to add from the items (like I showed you earlier) but we can add one manually.
Secondly, the SharePoint template won´t pick this up (the VS2010 environment will give us no intellisense)…you know why?
The template is not based on a web application project!
I just made a sanity check and instead added Microsoft.SharePoint as a reference to my web application project and added the config entries to that project instead…and:
As expected…the intellisense works as it should.
So, this is an issue I think.
I know some people might argue that SharePoint is not a web application in that sense and yada yada yada…but what I wan´t is a great developer experience in Visual Studio with intellisense on my stuff!!
I am aware of the fact that changes you make to the web.config file in VS are not provisioned to SharePoint, but as if you are working as a SP developer you should know this and also how to provision those changes if you like..after all there are numerous ways to accomplish that.
So, my mission was now to “force” VS2010 to understand both SharePoint-ish and Web Application-ish…is that even possible?
We will see…
// To be continued…
In part 2 of this post series I will show you how to make your SharePoint project in VS2010 understand that it is also a web application project