Visual Studio 2008 extensions for SharePoint : Project Templates or Item Templates

Probably the first thing you play with in the Visual Studio 2008 extensions for SharePoint is to create a web part. The default project naming can take a little to get used to however. Here's the common path that leads to confusion:

  1. Create your first WebPart project in Visual Studio - default project name WebPart1 and you get a Web Part project item template called WebPart1 also as the name of the WebPart feature. You can deploy and debug this web part to your local SharePoint Server.
  2. Create your second WebPart project in Visual Studio - default project name WebPart2 and you get a Web Part project item template called WebPart1 as the name of the WebPart feature. This is often not what you want, because the WebPart1 name will already be used on your SharePoint Server as an existing feature. So this project will fail to deploy unless you retract the previous WebPart1. Feature names on SharePoint must be unique.

The takeaway from this is that for each Visual Studio project template the default feature names start at 1 and unique feature names are required in SharePoint. Hence if you want to reuse the name WebPart1 on your SharePoint server, you have to deactivate and uninstall the previous one. You could use the SETUP.BAT from the first project for this, or you could use STSADM to remove it.

A better option would be to create Visual Studio projects using the Empty Project template (instead of the WebPart project) and then manually add your Web Part and give your Web Part a unique name yourself. It's unlikely that you would want to only have one WebPart in a SharePoint Visual Studio project anyway.

Comments

  • Anonymous
    November 17, 2008
    Probably the first thing you play with in the Visual Studio 2008 extensions for SharePoint is to create

  • Anonymous
    November 17, 2008
    Probably the first thing you play with in the Visual Studio 2008 extensions for SharePoint is to create

  • Anonymous
    November 19, 2008
    Come on guys this is week sauce.  Can’t believe someone would let this out the door.  

  • Anonymous
    December 04, 2008
    I have been changing file/class names since 05 extensions, I don't really see a problem anymore. I guess I am just desensitized!