一个好用的wsp打包工具-WSPbuilder

时间:2022-07-09 18:37:31
刚才在网上搜索关于Sharepoint的文章,在codeplex上搜到了一个刚发布不久的开源wsp打包工具WSPbuilder ,试了一下,感觉不错。WSPbuilder基于文件夹结构,要求先把相关文件整理到一个目录下面,这个目录下的文件夹名称及层次结构必须与Sharepoint保持一致,然后就能方便的制作wsp包了,而不必再去操作一些xml文件。
项目地址是 http://www.codeplex.com/wspbuilder,下面是项目的介绍及使用方法,英语比较简单,不翻译了:
Project Description
A SharePoint Solution Package (WSP) creation tool for WSS 3.0 & MOSS 2007

No more manually creating the manifest.xml file.
No more manually specifying the DDF file.
No more using the makecab.exe application.

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 creates a SharePoint solution manifest.xml and the wsp file based on the files it finds.
Therefore you do not need the knowledge of how to create a solution manifest.xml
and wsp file any more.

The folder structure that WSPBuilder uses to build the wsp file is actually the same folder
stucture you will find in: "%Program Files%\Common Files\Microsoft Shared\web server extensions\12"
So all that you have to do, is the create a \12 folder in your project and add your files to
that folder matching the same structure as if you where to put them directly into the
"%Program Files%\Common Files\Microsoft Shared\web server extensions\12" folder manually.

Lets say that you have created a SharePoint feature and you want to create a SharePoint Solution
for this feature. Then you just need to create the following folder structure in you project
directory: "[MyProject]\12\Template\Features\MyCustomFeature\" and put your feature files in
the MyCustomFeature folder, that being your feature. Then run the WSPBuilder from the your project
directory and it will automatically create the manifest.xml and pack it into a wsp file with the
content of the "\12" folder.

The WSPBuilder program fully supports the SharePoint Solution Schema meaning that it is possible
to create any kind of manifest.xml just by using folders. If the Solution Schema supports it, then
WSPBuilder can build it.

How to use the WSPBuilder

-------------------------

The WSPbuilder program builds WSP based on a folder structure.

Add your solution files to this folder structure and you do not need to specify any

thing else.

 

To auto generate the folder structure use the -createfolder argument.

To show the help use the -help argument.

Otherwise the wspbuilder will assume that you will build an manifest.xml and wsp file.

 

The root folder structure that WSPBuilder depends on looks like following:

 

12

80

GAC

 

The 12 folder represents the folders found in

"%Program Files%\Common Files\Microsoft Shared\web server extensions\12"

The 12 sub folders must have the same folder structure as the SharePoint 12 folder.

E.g:

12\ISAPI

12\Template\Features

12\Template\Layouts\1033

and so on.

Folders that are not used, do not need to be specified.

It is possible to define your own folders and they will be included in the solution.

 

If you want to build a Solution for a custom feature. Create the following structure.

"12\Template\Features\MyCustomFeature" and add your feature files to the MyCustomFeature

folder.

 

The 80 folder represents the WebApplication folder and contains following subfolders

80\bin, 80\wpcatalog, 80\resources. The 80\bin contains the dll's. If you have some

webpart definitions (webpart, dwp) files, they goes into the wpcatalog folder.

Any file can be added to the resource folder.

 

The GAC folder contains all DLL's that goes into the Global Assembly Cache on

installation. It is possible to define satellite assemblies within the same folder.

 

You can create the folder structure anywhere you like. But I prefer to add them in

the root of my SharePoint Visual Studio projects.

 

When you are done adding your files, just call the WSPBuilder application from the

root of the folder structure. The WSPBuilder has been setup with default setting to

automatically build a manifest.xml and WSP file. The manifest.xml file is automatically

included in the WSP file.

After the WSPBuilder application has run, it will create three files:

 

mysolution.wsp      The file name is default taken from the current folder.

manifest.xml        Contains the solution xml definition.

solutionid.txt      Contains the solution id for reusing on the next build.

 

 

If you want use the arguments, you use them as parameters or create a app.config for

the WSPBuilder application.

 

app.config

--------------------------------------

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

  <appSettings>

    <!--

    Optional settings

    You can set the arguments in this file or use them directly in the console.

    All arguments has a defualt value. See wspbuilder -help

 

    <add key="BuildCAS" value="" />

    <add key="BuildWSP" value="" />

    <add key="Createfolders" value="" />

    <add key="DeploymentTarget" value="" />

    <add key="Destination" value="" />

    <add key="Excludefiletypes" value="" />

    <add key="ExpandTypes" value="" />

    <add key="Help" value="" />

    <add key="Includefiletypes" value="" />

    <add key="ManifestEncoding" value="" />

    <add key="Outputpath" value="" />

    <add key="ResetWebServer" value="" />

    <add key="Silence" value="" />

    <add key="SolutionId" value="" />

    <add key="SolutionPath" value="" />

    <add key="WSPName" value="" />

    -->

  </appSettings>

</configuration>

 

 The app.config has to be located in the same folder as the WSPBuilder application.

 

 

 

Arguments list

---------------------------------------------------

-BuildCAS [true|false] (Default value is true)

Builds Code Access Security policy PermissionSets for assemblies found in the 80\bin folder.

If no evidence is found on an assembly, a default PermissionSet is defined with wss_medium settings.

 

-BuildWSP [True|False] (Default is true)

If set to true then the a WSP file will be generated.

 

-Createfolders [12|80|GAC|All] (All is default)

Creates the folder structure that supports building the wsp file.

 

-DeploymentTarget [GAC|BIN|Auto] (Default is Auto)

The defualt 'Auto' is that DLL's found in the \GAC folder is deployed to the Global Assembly Cache and DLL's found in the 80\bin folder are deployed to the virtual server bin directory

 

-Destination [Path] (Current directory is default)

The path to where the folders are created.

 

-Excludefiletypes ["cs,scc, ..."] (Default is 'cs,scc'. Use comma as a separator.)

Specifies which file types to exclude in the manifest and wsp file.   

Define more than one file type by using comma.   

It is possible to use asterisk '*' to exclude every file type, except those defined in the Includefiletypes argument.

 

-ExpandTypes [true|false] (Default is false)

Writes a SafeControl tag for every public type in the assembly.

 

-Help [Argument|Overview|Full] (Overview is default)

Use the help to show detail description of the arguments.

 

-Includefiletypes [*|xml,gif,jpg, ...] (Default is asterisk '*' meaning every file type. Use comma as a separator.)

Specifies which file types to include in the manifest and wsp file.   

If the file type if not defined in the Includefiletypes or in the Excludefiletypes arguments then it is always included.   

The Includefiletypes always overrules the Exludefiletypes argument.   

Define more than one file type by using comma.

 

-ManifestEncoding [UTF-8, UTF-16 and other standard encoding formats] (Default value is UTF-8)

Defines the encoding used in the manifest.xml file.

 

-Outputpath [Path] (Default is the current directory)

Specifies where the wsp and the manifest file are saved.

 

-ResetWebServer [true|false] (Default is true for GAC deployment and false for only bin deployment)

Resets the WebServer after installation.

 

-Silence [True|False] (Default is false)

If set to true, then there will no output to the console about the building process.

 

-SolutionId [GUID] (Default is taken from the solutionid.txt. The file will be automatically be created if it do not exist)

Specifies where the solution is located.

 

-SolutionPath [Path] (Default is the current directory)

Specifies where the solution is located.

 

-WSPName [name] (Default is the name of the solution folder)

Specifies the name of the wsp solution file.

 

Examples ----------------------------------

 

WSPBuilder -Createfolders All

 

WSPBuilder -SolutionPath C:\MyProject -Outputpath C:\MySolution

 

WSPBuilder -ExpandTypes true