Evgeny Tugarev

blog

  Home  |   Contact  |   Syndication    |   Login
  3 Posts | 0 Stories | 25 Comments | 2 Trackbacks

News



Archives

Image Galleries

For those who are new to the SharePoint solutions and features I would recommend to try the SharePoint Solutions Generator, which is a part of the Windows SharePoint Services 3.0 Tools: Visual Studio 2005 Extensions. It is a windows stand-alone application that converts your existing SharePoint web site into the solution package and creates a Visual Studio project for you to use. Nice isn’t it?

What I personally don’t like in the automatic tools is that they always hide some part of the job they are doing behind the scenes. In this scenario you can’t really control and sometimes understand of that is going on. So, today I would like to blog about of how to manually create the SharePoint feature containing the list, how pack it into the solution package and finally deploy it to the production server.  Everything will be done without any use of Visual Studio or other tools (only Notepad++).

So, let’s start!

Step 1. Folders

First, create the folder structure for the solution. I used MySolution but you can give a name whatever you want. Two folders were created beneath MySolution - source and bin. First is for the compiled package, second – to keep the feature and the customized list. I use the same file structure for the feature as in SharePoint - one folder per feature.  Check out your SharePoint features hive at C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\DiscussionsList and see how it’s organized.
 In the source folder I made the feature folder called MyList and 2 subfolders inside - List Templates and Messages.  In the end you will have something like this:

Step 2. Building a Feature.

Here we create our feature based on the SharePoint discussions list. Go to MyList folder and create a file feature.xml, where we reference 2 files, first – list manifest  MyListManifest.xml  and the second – schema.xml  which is describing the list metadata. And don’t forget to change the GUID of feature Id with your own!

feature.xml

<?xml  version="1.0" encoding="utf-8"?>
<Feature Id="A8E6B85F-D81A-4cc1-9708-D15FEF359DE2"
    Title="My Feature"
    Description="This is my feature containing a list"
    Version="1.0.0.0"
    Hidden="FALSE"
    Scope="Web"
    DefaultResourceFile="core"
    xmlns="http://schemas.microsoft.com/sharepoint/">
    <ElementManifests>
      <ElementManifest Location="ListTemplates\MyListManifest.xml" />
      <ElementFile Location="Messages\schema.xml"/>
    </ElementManifests>
</Feature>

Copy the original schema.xml file from the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\DiscussionsList\Discuss folder to the Messages folder, and you have a list schema to start from, MyListManifest.xml we’ll create manually in the ListTemplates folder –

MyListManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <ListTemplate
    Name="Messages"
    Type="108"
    BaseType="0"
    OnQuickLaunch="FALSE"
    FolderCreation="FALSE"
    SecurityBits="12"
    Sequence="999"
    DisplayName="My List"
    Description="This is my custom list based on the discussions list"
    Image="/_layouts/images/itdisc.gif"/>
</Elements>

What is important here is that the Name attribute must have the same name as the folder where schema.xml is placed, Messages, as SharePoint will look for the schema.xml file at that location!

After the end of this step you have 3 new files as seen on the picture

Step 3. Building a Solution Package (.wsp)

SharePoint Solution Packages (wsp ) provide a great way to distribute all your customization in just one flask and the creation of the .wsp  ain’t so painful operation as you may think, I would say it is easy as hell! Everything starts from the traditional solution manifest .xml file in the Source folder:

manifest .xml

<?xml version="1.0" encoding="utf-8"?>
<Solution xmlns="http://schemas.microsoft.com/sharepoint/"
          SolutionId="EC2EFD73-DBA2-4c0e-9C18-C8FC43F72E6C" >
  <FeatureManifests>
    <FeatureManifest Location="MyList\Feature.xml"/>
  </FeatureManifests>
</Solution>

Here, we reference our Feature.xml file that we had created before at the Step 2, and as you may guess it’s a good way to replace the the SolutionId GUID with something brand new J.  The next that should be created is the data definition file (.ddf). It’s a simple text file with the building instructions for the makecab utility because the .wsp package is nothing more than a cabinet file with the .wsp extension. (If you rename .wsp or .stp file to .cab you’ll be able to see its contents).  Let’s create a wsp.ddf in the Source folder:

wsp.ddf

.OPTION Explicit
.Set DiskDirectory1="..\bin"
.Set CabinetNameTemplate="MyListSolution.wsp"

manifest.xml

; These directory names (DestinationDir) are used for the folders creation under 12\TEMPLATE\Features

.Set DestinationDir="MyList\ListTemplates"
MyList\ListTemplates\MyListManifest.xml

.Set DestinationDir="MyList\Messages"
MyList\Messages\schema.xml

.Set DestinationDir="MyList"
MyList\Feature.xml

In this file we set an output folder for the compiled package..\bin, its name MyListSolution.wsp and we tell makecab to include 4 files (marked in red) and create 3 folders at the deployment phase (in blue). Now it’s time to build everything into a single file, but before we do that I create a build.cmd file in the Source folder with some lines to facilitate the building process

build.cmd

@setlocal
@pushd.

 @cd %~dp0

 makecab /f wsp.ddf

@popd
@endlocal

Here I reference the wsp.ddf file with processing instructions which I created before. After you run it your solution package will appear in the bin folder:

Step 4. Solution deployment.

So, the solution package has just been created and the last thing that is left to do is to deploy it to our production server. I always like then the script is doing my job, so I put 2 .cmd files into the bin folder to deploy and retract my.wsp package so I don’t have to deal with stsadm utility from command line.

 

DeployMyListSolution.cmd

@setlocal
@pushd.

@set PATH=C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN;%PATH% @cd %~dp0

 stsadm.exe -o addsolution -filename MyListSolution.wsp
 stsadm.exe -o deploysolution -name MyListSolution.wsp -local

@pause
@popd
@endlocal

RetractMyListSolution.cmd

@setlocal
@pushd.

@set PATH=C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN;%PATH% @cd %~dp0

 stsadm.exe -o retractsolution -name MyListSolution.wsp –local
 stsadm.exe -o deletesolution -name MyListSolution.wsp

@pause
@popd
@endlocal

 

After the solution is deployed you can activate the feature in the Site features menu of you site and start using the new list!
 

Step 5. Using the feature.

Before our custom list can be used the feature containing it must be activated within the SPWeb scope.

After activation is done your custom list will appear on the site’s create page and you can create list instances!

 

Have fun!
Next time I will talk about site definitions inside the solutions.

Evgeny Tugarev.

posted on Sunday, January 27, 2008 12:38 PM

Feedback

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 1/29/2008 11:43 PM Susantha
This is really useful, But still I haven't tried this out. After this comment, I am going to try this.

Thanks.

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 1/30/2008 1:08 AM Susantha
You have shown how to create a link which point to the existing discussion list.

I need to know how to create a link which point to a custom .aspx page which I have created. once i click on that link, that my custom aspx file should open, but all the navigation bars and master page in share point server should be remain the same.

Which steps I have to change for this task?
Can you please give some hints..?

Thanks.

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 3/19/2008 12:48 PM Evgeny
Sorry for the late responce, I haven't been looking into my blog for a some time. The thing you are trying to do can be done in many ways and one of the opportunities is to include the link into onet.xml file in <NavBars> sections. This might be helpful http://msdn2.microsoft.com/en-us/library/ms868602.aspx
The way I can point is the site templates :)


# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 5/21/2008 11:27 PM Bhavdip Shah
Hi,

I worked with MOSS and WSS since last 1.5 years and my most of development was carried on at client's live Sharepoint server.

Right now, I need to create a WSP file which also responsible to deploy the variations with it, My SharePoint site is fully customized with UI design (Master Page), Webparts, Custom WebPart, utility and all... and also it supports Multilingual environment with Chinese (Simplified), English (US), Dutch (Netherland) language.

I have surf many sites, still I could not get proper help from any of the resource, for building a WSP solution package in a fully customized Multilingual environment.

Plz. Help me in this matter...

-Thanks in Advance !!!

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 5/22/2008 4:03 PM Mike Fagan
What does your schema.xml look like. That is the problem I am having is formatting that file correctly and getting what is necessary in it.

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 5/28/2008 2:21 AM Bhavdip Shah
Thanks for your prompt reply...

But It creates a schema.xml file in each and every folder within it...

and each and every file was generated from the utility itself and almost it is properly nested, with anyway...

My problem was to packaged the Sites with Customized css, Images, Variations (Subsites associated with all its pages), Custom Lists and all...

User just needs to run the STSADM command line utility for Installing the package (WSP) and he has all these things that is already available in the site from which it is generated...

Waiting for your prompt reply...

-Thanks in Advance !!!

-Bhavdip Shah
(Software Engineer)


# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 5/28/2008 3:27 PM Evgeny
Hi,

I am not sure that I understand correctly your question..
you can include everything that you need on your site in just one schema.xml file - look at the sharepoint solution generator how it works and the project that it generates in Visual Studio.
Another possibility for you is save your site as a .stp template.
It can be added later on to the production environment using stsadm tool.

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 6/18/2008 5:51 PM Nicolas
Hi

Great article, but i have a question. If i have a site, and i add another sites, lists, calendars, etc on it, i would like to create a template for my "master" site, so when i create a new instance of my master site, it will be deployed with everything on it. I tried to do this, saving the master site as a .std template, but when i try to use it, it doesn't contains any child elements (sites, lists, etc...)

Hope you could help me. Regards,

Nicolas

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 6/20/2008 3:32 AM Evgeny
Hi

Look at the site definitions, not site templates. You'll find more information here -
http://msdn.microsoft.com/en-us/library/aa978512.aspx

Cheers,
Evgeny

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 8/19/2008 2:44 PM Satyen
Evgney,
Hats off to you for your effort into this. Before reading your blog I was so confused with Features and Solutions in SharePoint. You nailed it....I mean you nailed it to the bottom. Everything is so clear now.

I am looking forward for your articles.

10.1 on scale of 1 to 10.

-Satyen

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 9/24/2008 7:11 PM yogendra
thankyou very much dude.


it's working for me.

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 10/15/2008 4:13 AM Arnold
An excellent article. Thank you!

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 10/15/2008 11:22 PM chinkul
Hi

If i create a site definition with the SP Solution generator, and if this definition has some web parts and i add them in the webpart pages availabe as part of the definition.
Say if i have deployed this site definition and created subsite, and then when i make changes to the webparts, will it still reflect in the subsite that i created with this site defnition?

If it does not reflect, what should i do, so that it reflects in all instances of webparts.
i definetly need this, as we are working on creating site definition with webparts.

You have done a great job!
Thanks for your help.

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 10/30/2008 8:09 AM Rachel
Will this work for infopath forms and form services?

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 11/22/2008 6:54 AM Rao Kamran Anwar
This is a great article. It really helped me a lot and it. I am thankful to the writer for sharing this article.

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 12/10/2008 8:28 AM cephus
Very nice. It worked out just as you explained. Thanks for taking the time to write this. Much appreciated!

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 12/18/2008 11:12 PM Dan
Can I ask what you mean by "And don’t forget to change the GUID of feature Id with your own!"

I assume that this is all done from scratch so there isnt a GUID to use... unless you meant generate a fresh random GUID?

Is that what you meant?

Thanks in advance!

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 12/19/2008 4:24 AM Evgeny
Hi Dan,

This is just to be sure that FeatureId Guid A8E6B85F-D81A-4cc1-9708-D15FEF359DE2 is only used in this example feature. If you do copy-paste you can easily forget to replace guid with new one.

Cheers,
Evgeny

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 12/19/2008 5:08 PM Dan
Thanks Evgeny,

It worked first time for me. Great post!

I'll be trawling through the rest of your blogs for similar nuggets of gold!

Regards
Dan

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 1/5/2009 9:47 AM Jonathan Camilleri
I have created a sharepoint site and I need to port it to another machine. The site consists of a couple of lists and discussions; and they were created using sharepoint.

Just guessing...
I was thinking of copying the files within the
c:\inetpub\wwwroot\wss\VirtualDirectories\21352, within the new machine, but then I'd need to configure them within IIS and sharepoint I presume.

Any idea how to do this?

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 1/7/2009 3:50 AM jayanth
Hey i need to create a WSP to a webservice .
Is it possible as i tried the above mentioned method but it didn't work .
Any help????

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 2/2/2009 9:38 AM n8
Very nice, bro! This really simplified things for me.

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 3/14/2009 9:36 AM dll
I have to say….thanks….this article is much more clear and efficient…

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 4/20/2009 12:24 AM Mahendra
Hi,

I want to create a sharepoint site like the below can you please guide

http://www.kroger.com/Pages/default.aspx

# re: Creating a SharePoint Solution Package (.wsp) in 5 steps 5/8/2009 7:47 AM Sreenath
Hi Evgeny

I was following your blog post step to step to package an existing picture lib into a solution and deploy on a destination server.

I however faced the following issue:
The list when deployed gave an error: "File Not Found", but still had deployed the solution. When I created an instace of the list, I found that it had no views, although I had packaged all the view .aspx files in the wsp and had included all the appropriate paths. Also it did not allow me to create views on the create instance and errored out.

I later found that the solution to this error was in the Feature.xml where I needed to include references to the view .aspx as well using the ElementFile tag as below:
..
<ElementFile Location="Schema\Schema.xml" />
<ElementFile Location="Schema\AllItems.aspx" />
..
After adding these tags in the Feature.xml, everything worked.

I don't know if you have missed this in your tutorial or I am going wrong somewhere in following your steps. Just let me know what I could be missing.

Cheers
Sreenath

Post Feedback

Title:
Name:
Email: (never displayed)
Url:
Comments: