Although many methods are provided on the Internet, most of them require third-party tools. In fact, this work is very simple and it may be easier to do it by yourself.
Step 1: Create a WebPart. Assume It is SearchBoxWebPart and name it strongly (strong naming is not required, but is recommended );
Note: Add [assembly: AllowPartiallyTrustedCallers ()] to AssemblyInfo. cs.
And AssemblyVersion
Step 2: Create a CAB Project and add two files, manifest. xml and SearchWebPart. dwp.
The content of manifest. xml is:
<? Xml version = "1.0"?>
<WebPartManifest xmlns = "http://schemas.microsoft.com/WebPart/v2/Manifest">
<Assemblies>
<Assembly FileName = "SearchWebpart. dll">
<SafeControls>
<SafeControl Assembly = "SearchWebPart, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = e01f55ae71a39d56" Namespace = "SearchWebPart" TypeName = "*" Safe = "True"/>
</SafeControls>
<ClassResources>
</ClassResources>
</Assembly>
<Assembly FileName = "Microsoft. SharePoint. dll">
<SafeControls>
<SafeControl Assembly = "Microsoft. SharePoint, Version = 12.0.0.0, Culture = neutral, PublicKeyToken = 71e9bce111e9429c" Namespace = "Microsoft. SharePoint" TypeName = "*" Safe = "True"/>
</SafeControls>
<ClassResources>
</ClassResources>
</Assembly>
<Assembly FileName = "Microsoft. Office. Server. dll">
<SafeControls>
<SafeControl Assembly = "Microsoft. office. server, Version = 12.0.0.0, Culture = neutral, PublicKeyToken = 71e9bce111e9429c "Namespace =" Microsoft. office. server "TypeName =" * "Safe =" True "/>
</SafeControls>
<ClassResources>
</ClassResources>
</Assembly>
<Assembly FileName = "Microsoft. Office. Server. Search. dll">
<SafeControls>
<SafeControl Assembly = "Microsoft. office. server. search, Version = 12.0.0.0, Culture = neutral, PublicKeyToken = 71e9bce111e9429c "Namespace =" Microsoft. office. server. search "TypeName =" * "Safe =" True "/>
</SafeControls>
<ClassResources>
</ClassResources>
</Assembly>
<Assembly FileName = "Microsoft. SharePoint. Publishing. dll">
<SafeControls>
<SafeControl Assembly = "Microsoft. sharePoint. publishing, Version = 12.0.0.0, Culture = neutral, PublicKeyToken = 71e9bce111e9429c "Namespace =" Microsoft. sharePoint. publishing "TypeName =" * "Safe =" True "/>
</SafeControls>
<ClassResources>
</ClassResources>
</Assembly>
<Assembly FileName = "Microsoft. SharePoint. Search. dll">
<SafeControls>
<SafeControl Assembly = "Microsoft. sharePoint. search, Version = 12.0.0.0, Culture = neutral, PublicKeyToken = 71e9bce111e9429c "Namespace =" Microsoft. sharePoint. search "TypeName =" * "Safe =" True "/>
</SafeControls>
<ClassResources>
</ClassResources>
</Assembly>
<Assembly FileName = "Microsoft. SharePoint. Security. dll">
<SafeControls>
<SafeControl Assembly = "Microsoft. sharePoint. security, Version = 12.0.0.0, Culture = neutral, PublicKeyToken = 71e9bce111e9429c "Namespace =" Microsoft. sharePoint. security "TypeName =" * "Safe =" True "/>
</SafeControls>
<ClassResources>
</ClassResources>
</Assembly>
</Assemblies>
<DwpFiles>
<DwpFile FileName = "SearchWebpart. dwp"/>
</DwpFiles>
</WebPartManifest>
The dll specified by Assembly is installed in the bin directory of SharePoint.
The content of SearchWebPart. dwp is:
<? Xml version = "1.0" encoding = "UTF-8"?>
<WebPart xmlns = "http://schemas.microsoft.com/WebPart/v2">
<Title> SearchWebpart </Title>
<Description> Custom search web part </Description>
<Assembly> SearchWebPart, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = e01f55ae71a39d56 </Assembly>
<TypeName> SearchWebPart. SearchBoxWebPart </TypeName>
</WebPart>
It specifies the WebPart to be installed.
Step 3: add all required dll files to the CAB Project.
Step 4: run the stsadm command to install the SDK.
Install: stsadm-o addwppack-filename C: \ SearchWebpartSetup. CAB-url [URL if you want to deploy to a specific site]
Uninstall: stsadm-o deletewppack-name SearchWebpartSetup. CAB