which country user step here?

Tag Cloud

MOSS (47) SharePoint 2007 (37) SharePoint 2013 (31) SharePoint 2010 (23) MOSS admin (17) PowerShell (17) admin (17) developer (16) List (15) WSS (14) sql query (14) MOSS SP2 (13) end user (11) scripting (11) wss V3 (11) permission (10) sql (9) Moss issue (8) search (8) database (7) RBS (6) Service Pack (6) reportadmin (6) workflow (6) CU (5) Excel (5) Patch (5) client object model (5) Client Code (4) Command (4) Cumulative Updates (4) IIS (4) SharePoint 2019 (4) SharePoint designer (4) office 365 (4) stsadm (4) user porfile (4) ASP.NET (3) Content Database (3) Groove (3) Host Named Site Collections (HNSC) (3) SharePoint 2016 (3) Tutorial (3) alert (3) authentication (3) batch file (3) codeplex (3) domain (3) error (3) incomming email (3) issue (3) restore (3) upload (3) Caching (2) DocAve 6 (2) Folder (2) Index (2) Internet (2) My Site Cleanup Job (2) My Sites (2) News (2) People Picker (2) Share Document (2) SharePoint admin (2) View (2) Web Development with ASP.NET (2) add user (2) audit (2) coding (2) column (2) deploy solution (2) download (2) enumsites (2) exam (2) export (2) june CU (2) load balance (2) mySites (2) network (2) orphan site (2) performance (2) profile (2) project server (2) query (2) security (2) server admin (2) theme (2) timer job (2) training (2) web master (2) web.config (2) wsp (2) 70-346 (1) 70-630 (1) AAM (1) Anonymous (1) Approval (1) AvePoint (1) Cerificate (1) Consultants (1) Content Deployment (1) Content Type (1) DOS (1) Document Library (1) Drive Sapce (1) Excel Services (1) Export to Excel (1) Feature (1) GAC (1) Get-SPContentDatabase (1) Get-WmiObject (1) HTML calculated column (1) ISA2006 (1) IT Knowledge (1) ITIL (1) Install (1) Link (1) MCTS (1) Macro (1) Masking (1) Migration (1) NLBS (1) Nintex (1) Office (1) Open with Explorer (1) ROIScan.vbs (1) Reporting Services (1) SPDisposeCheck.exe (1) SQL Instance name (1) SSRS (1) Sandbox (1) SharePoint Online (1) SharePoint farm (1) Shared Services Administration (1) Site Collection Owner (1) Site template (1) Skype for business (1) Steelhead (1) Teams (1) URLSCAN (1) VLOOKUP (1) WSS SP2 (1) XCOPY (1) abnormal incident (1) admi (1) app (1) application pool (1) aspx (1) availabilty (1) backup (1) binding (1) blob (1) branding sharepoint (1) cache (1) calendar (1) change password (1) connection (1) copy file (1) counter (1) crawl (1) custom list (1) domain security group (1) event (1) excel 2013 (1) facebook (1) filter (1) fun (1) group (1) iis log (1) import (1) import list (1) improment (1) interview (1) keberos (1) licensing (1) log in (1) metada (1) migrate (1) mossrap (1) notepad++ (1) onedrive for business (1) operation (1) owa (1) process (1) publishing feature (1) resource (1) send email (1) size (1) sps2003 (1) sql201 (1) sql2012 (1) sub sites (1) system (1) table (1) task list (1) today date (1) trial (1) vbs (1) video (1) web part (1) web server (1) widget (1) windows 2008 (1) windows 2012 R2 (1) windows Azura (1) windows account (1) windows2012 (1) wmi (1)

Wednesday, June 23, 2010

Creating a SharePoint Solution Package (.wsp) in 5 steps – from Evgeny Tugarev

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 theWindows 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 beneathMySolution - 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 themakecab 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 theSource 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.

1 comment:

林奕廷 said...
This comment has been removed by a blog administrator.