• Grumpy Wookie

    View Chris OConnor's profile on LinkedIn

  • Archives

  • Top Posts

  • Flickr Photos

    4780_113082538658_784073658_2905444_7437417_n

    4780_113082533658_784073658_2905443_6843979_n

    4780_113082528658_784073658_2905442_8369531_n

    4780_113082523658_784073658_2905441_776992_n

    4780_113082518658_784073658_2905440_3601069_n

    4780_113082513658_784073658_2905439_2663807_n

    More Photos
  • Recent Visitors

  • Blog Stats

    • 177,329 hits

SharePoint WebPart Project templates for Visual Studio 2008

One of the tricky bits with developing WebParts using Visual Studio 2005 is the deployment aspects. 

As mentioned in this article, you firstly have to create a strong-name key, and compile the DLL, load the assembly into the GAC, and include as a SafeControl.

There are STSADM scripts that can be used to do the same thing – the project I’m currently working on has a installfeature script for each WebPart.

With the release of Visual Studio 2008, there are some new project templates available on codeplex.

The SmartTemplates for SharePoint project delivers a collection of Visual Studio templates which allow developers to create a range of SharePoint customizations in a painless and professional fashion.

The SharePoint Web Part project template for Visual Studio allows developers to create quickly a project which contains the base infrastructure to:

  • write the web part code
  • generate a SharePoint Solution file (WSP) for easy deployment
  • generate a setup package for a wizard driven installation

You simply create a new project as a SharePoint WebPart (Smart Template), and build the functionality and layout as normal.

image

When you compile the DLL, there is a post-build step that runs a batch command (createwsp.bat).

This uses the WSPBuilder console application also available on codeplex.

The WSPbuilder is a console application that creates SharePoint Solutions files based on a folder structure.

WSPBuilder will automatically traverse a “12″ folder structure and create the SharePoint solution manifest.xml and the wsp file based on the files it finds.

Therefore knowledge of how to create a solution manifest.xml and wsp file is not needed any more.

The result of the “build” step within Visual Studio is that a SETUP.EXE file is created.  You simply jump out to Windows Explorer – and run the SETUP.EXE !

The wizard even checks to see you have adequate permissions & system requirements in place.

image

You can then choose which Web Application to “add to SafeControls” :

image

It registers the DLL in the GAC, adds the feature (installfeature) and activates the feature (WSP) for each chosen Web Application.

When the wizard completes, just have to flip back to SharePoint to turn it on for each particular Site Collection :

  • Site Settings > Site Collection features > Activate

The WebPart will then be available from the WebPart gallery, and can be added to a page.

This is a great time-saver – making deployment of WebParts much easier.

Only problem is – it’s for Visual Studio 2008 – don’t know if that means you have to use .NET 3.5 – or can continue to development WebParts with .NET 2.0 (target framework option within VS 2008).

Click here for more details, and download link.

14 Responses

  1. With VS 2008 you can decide which .NET Framework you are targeting, so it’s no problem to develop WebParts with .NET 2.0.

    jan

    • I am using vs 2008 and Sqlserver 2008 to develop webparts.

      I did same thing what you mentioned in this artical.

      And I did activatgion also.
      Using : Site Settings > Site Collection features > Activate.

      The WebPart available in the WebPart gallery, But I am unable to add the webpart.

      when i am trying to add webpart, the following error message was shown.

      Unable to add selected webpart(s) ,
      Webpart1 : A webform or webpart control on this page can not be displayed or imported the type couldn’t be found or it is not registered as safe.

  2. I am unable to find the SharePoint Smart Templates (which will be near to Online template) in the dialog box. How to add it in the New Project Dialog box?

  3. You need to download and install the SmartTemplate project – http://www.codeplex.com/smarttemplates

  4. I would like to use the SmartTemplates, but codePlex tells me that I have to be coordinator or developer to access the site.

  5. I, too, would like to use the SmartTemplates project, but am also getting the message that I have to be a coordinator or developer to access the site. CodePlex is saying that the project “is not yet published.” Is this true? If so, when will it be? No offense intending, but after reading your blog entry, I was all psyched up to get to use the project; now I feel like you’re just toying with me!

  6. I too am unable to get to the smarttemplates…please advise.

  7. It is for C# only! If you want to use VB.NET –> Tough luck! (Status quo 10/2008)

  8. If you want to use the template in VB.NET you have to download this Zip-File: http://www.codeplex.com/smarttemplates/WorkItem/AttachmentDownload.ashx?WorkItemId=968&FileAttachmentId=663

    The work item “VB.NET version of the templates
    ” says:

    This ZIP file contains the VB.NET version of the project template. Copy this file in your “Visual Studio 2008\Templates\ProjectTemplates\Visual Basic” folder.
    (Update from sharepointbook.de)

  9. i dont think this will work, if it works for you good luck :-)

  10. My dev environment does not have Sharepoint installed – I have a virtual PC that does not have VS installed but WSS is installed on it.

    Is there something I can do to use setup to install my new webpart that I just developed in VS to the VM or another server?

  11. This is indirectly related to the SmartTemplate, which I have not yet tried:
    I’ve installed the Visual Studio 2008 (SP1) Extensions for WSS 3, and tried to create a new WebPart project. However, Visual Studio only makes the WebPart project type available when I target the project to .Net version 3.5. This is confusing for me because I understand WSS 3 is based on version 2 of the Framework.

    Will a webpart project, or one based on the SmartTemplate, set to use .Net 3.5 work when deployed to a WSS 3 site?

    Thanks in advance.

    M.

  12. I am just wondering if I can create more than 1 webpart in the project and deploy them together but in the web gallery will have the multiple web parts i created?

Leave a Reply