What is a SharePoint 2007 Solution

Thursday, 19 March 2009 21:39 by myro

Understanding Solutions in SharePoint 2007

There are many ways to deploy your customizations in SharePoint 2007, for example a custom web part can be easily integrated adding the DLL in GAC and declaring the the control as safe in your web application's Web.Config. Unfortunately this is not the best way to add your customization in SharePoint 2007 because you will never have a clear reference of what have been customized in your farm. The best approach is always to develop a SharePoint Solution, which helps SharePoint to know how to install and/or retract it. The Windows SharePoint Services SDK describes solutions in this way:

The Windows SharePoint Services solution framework provides a way to bundle all the components for extending Windows SharePoint Services in a new file that is called a solution file. A solution file has a .CAB-based format but a .WSP extension. A solution is a deployable, reusable package that can contain a set of Features, site definitions, and assemblies that apply to sites, and that you can enable or disable individually. You can use the solution file to deploy the contents of a Web Part package, including assemblies, class resources, .dwp files, and other package components. (read more).

In this page, you will learn how to create a Solution based on a Site Definition using SharePoint Solution Generator.
First of all, create a new Site Collection (Central Administration > Application Management > Create Site Collection) selecting the Team Site Template. In my case i will use an existing Web Application located on http://myro-win2k3:90/ . Press the Ok button and navigate to your new site collection.
Once you are in, lets make some personalization:

  • Navigate to /_layouts/create.aspx
  • Create a custom list named "Sample List
  • Add a column named "Sample Column", selecting "Single line of text" as type.
  • Navigate to /_layouts/create.aspx

Now that we have a new Site with some customizations we can open SharePoint Solution Generator to create our new custom Site Definition,  based on this site.

  • In the first step, choose Site Definition
  • next, specify your site's url ( in my case is http://myro-win2k3:90/default.aspx )
  • then check just Form Templates and Sample List in a Pick a SharePoint List step
  • Specify save location writing "mySolution" as Project Name
  • Check if the target site is correct and press Finish

Wait untill Solution Generator completes the task and then open the mySolution.csproj with Visual Studio 2005. The first thing we must try is to deploy the solution in SharePoint.... Click Build -> Deploy. Automatically Visual Studio will try to deploy it in http://localhost/ but if you need to deploy it on a different site click Project -> mySolution Properties -> click the Debug tab -> and set your target site in Start Action -> Start Browser with Url.
If your deploy is succesfully you can create your first site based on your Custom Site Definition, but where is the fun? This Site Definition is not yet custom, till we don't customize! Yell

Let's try out:
The Form Templates is a List Definition of a Document Library and this folder contains all the ASPX pages needed for your customizations. Open the DispForm.aspx under Form Templates locate on top the PlaceHolderPageTitleInTitleArea PlaceHolder and add this line:

 <asp:Content ContentPlaceHolderId="PlaceHolderPageTitleInTitleArea" runat="server">
  <h3>!This is a personalization!<h3>
  <SharePoint:ListProperty Property="LinkTitle" runat="server" id="ID_LinkTitle"/>: <SharePoint:ListItemProperty id="ID_ItemProperty" MaxLength="40" runat="server"/>
<asp:Content>

t's easy to understand that customizing this pages you can modify almost everything. We have just added some text in the DispForm.aspx, infact if you add a new document to this library and view the properties (DispForm.aspx) you see the changes you made before:

 

The ListDefinition.xml is used to set some properties concerning this definition like the diplay name and the desciption. The Schema.xml file has several usefulness: it says how to render the list, which event handlers are binded, it sets some security policies, etc...
You can make any customizations to the Sample list as well; the only difference is that you modify a SharePoint List and not SharePoint Document Library.
Site Definition folder contains 2 files: the Default.aspx site's home page (yes... you can customize it too..) and the onet.xml file which contains many properies about your site definition and can serve multiple functions, such as the following (from msdn):

  • Specify an alternate cascading style sheet (CSS) file, JavaScript file, or ASPX header file for a site definition.
  • Modify navigation areas for the home page and list pages.
  • Add a list definition as an option to the Create page.
  • Add a document template for creating document libraries.
  • Define one or more configurations for the site definition, specifying the lists, modules, files, and Web Parts that are included when a site definition configuration is instantiated.

If you want to add some custom actions when your solution is activated, you can write your code in the SiteProvisioning.cs but for now just skip this step.

Now that you have understand better what is a solution and how to deploy it, you want to know  for sure how can you install it in your production enviroment. Here comes STSADM.EXE!

Stsadm provides a method for performing the Office SharePoint Server 2007 administration tasks at the command line or by using batch files or scripts. Stsadm provides access to operations not available by using the Central Administration site, such as changing the administration port. The command-line tool has a more streamlined interface than Central Administration, and it allows you to perform the same tasks. There are certain operations and certain parameters that are only available by using the Stsadm command-line tool. (from TechNet)

Navigate to \mySolution\bin\Debug and you will notice that Visual Studio has created several files and a solution folder. The most important file is mySolution.wsp: it is a CAB file that contains all the neccesary files to install the solution in SharePoint 2007. You can use the Setup.exe to  perform a clean install of your solution, but let use some STSADM commands instead.
First, open your Central Administration > Operations > Solution Management and you will see that mySolution.wsp is correctly deployed. What will do next is to retract the solution, delete it and finally reinstall it.

 

C:\...\mySolution\bin\Debug>stsadm -o retractsolution -name mysolution.wsp -immediate

Operation completed successfully.

C:\...\mySolution\bin\Debug>stsadm -o execadmsvcjobs

Executing .

Executing solution-deployment-mysolution.wsp-0.

Operation completed successfully.

C:\...\mySolution\bin\Debug>stsadm -o deletesolution -name mysolution.wsp

Operation completed successfully.

C:\...\mySolution\bin\Debug>stsadm -o execadmsvcjobs

Executing .

Operation completed successfully.


And now re-deploy:

C:\...\mySolution\bin\Debug>stsadm -o addsolution -filename mySolution.wsp

Operation completed successfully.

C:\...\mySolution\bin\Debug>stsadm -o execadmsvcjobs

Executing .

Operation completed successfully.

C:\...\mySolution\bin\Debug>stsadm -o deploysolution -name mySolution.wsp -immediate -allowGacDeploy

ment -force

Timer job successfully created.

C:\...\mySolution\bin\Debug>stsadm -o execadmsvcjobs

Executing .

Operation completed successfully.


Congratulations!!! You have learned how to manage Solutions in SharePoint 2007!

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   SharePoint 2007
Actions:   Bookmark and Share | Permalink | Comments (7) | Comment RSSRSS comment feed
If you consider this post usefull for your purposes, please consider visiting my sponsors to help me out with the myrocode.com maintenance. Thank you.

Comments