Simple Tip when creating VS projects for sharepoint 2010

One thing I’ve noticed is that when you create a SharePoint project in VS 2010 (File, New, Project) and create a name for your project it doesn’t get persisted down to the project item. For example, create a new Visual Web Part project; you’ll notice that your default naming convention follows VisualWebPart1 for the web part that is added to the default top-level SharePoint project. 


If you create a new Visual Web Part project called MyFirstVisualWebPart you’ll see that the ensuing project item that’s created does not prompt you for a name for your web part. To change this, you need to Edit, Replace All with the name you want in your solution.


A simple workaround is to first create an empty SharePoint project and then add a SharePoint project item (SPI) to the empty project. In the case of the above, your top-level project would be called MyFirstVisualWebPart and then when VS creates the project structure, use the item-level templates to add a Visual Web Part to the project. What results is something as per the below: a web part with the naming convention you assign to at creation time.


Simple, but may save you some time in the long run if you’re new to VS 2010. You’ll also find that this will apply to other item-level templates as well.

Note: If you do follow this model, be sure to create the top-level empty SharePoint project in the proper trust level (e.g. for project templates that will not build at the sandboxed level be sure to create the top-level empty project as full trust (farm-level)).

Hope this helps a few of you.


Comments (0)

Skip to main content