How to Add Additional WebParts to a Solution

Feb 21, 2008 at 6:12 PM
I've spent considerable time trying to add additional web parts to my solution successfully, so I thought I'd post on the discussions tab rather than issues to start with. I ran into issues on our dev servers, so I went back in painstaking detail documenting every step I took on a VPC and ran into the same issues. So either I'm missing something, something is wrong with my environment, or there is an issue with the tool.

My question is has anyone been able to add new web parts to a solution (other than CustomWebPart1 and 2) that deploy automatically into the web part gallery?

I basically started by renaming CustomWebPart1 to MyWebPart and deleting CustomWebPart2.
For MyWebPart I did the following:
Renamed CustomWebPart1.cs to MyWebPart.cs
Renamed CustomWebPart1.webpart to MyWebPart.webpart
Performed find in files in the solution on "CustomWebPart1" and replaced with "MyWebPart" in SolutionPackage.ddf, feature.xml, MyWebPart.cs, MyWebPart.webpart, webparts.xml
I did a BuildDeploy and this worked. I activated the feature in the site collection features. I went to a page and added a web part and MyWebPart was there.

So then, I wanted to add an additional webpart to the solution.
I copied MyWebPart.cs and renamed it as CopiedWebPart.cs
I copied MyWebPart.webpart and renamed it as CopiedWebPart.webpart
I performed a find in files in the solution for "MyWebPart" and added statements for "CopiedWebPart" in SolutionPackage.ddf, feature.xml, CopiedWebPart.cs, CopiedWebPart.webpart, webparts.xml.
I also modified the label for MyWebPart.cs so I could see if it changed.
I then did a BuildRedeploy.


IT DID NOT DEPLOY CopiedWebPart to the WebPart Gallery
IT DID COPY CopiedWebPart.webpart to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\RenamedWebPart\WebParts
MyWebPart.cs was updated with new label on my web part page
I have copied my output file to the bottom of this post for reference.

At this point I'm stuck with having to manually add the web part to the web part gallery by browsing to my .webpart file at C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\RenamedWebPart\WebParts


------ Build started: Project: RenamedWebPart, Configuration: DebugRedeploy Any CPU ------
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /nowarn:1701,1702 /reference:"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\Microsoft.SharePoint.dll" /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /keyfile:KeyFile.snk /out:obj\DebugRedeploy\RenamedWebPart.dll /target:library CopiedPart.cs Properties\AssemblyInfo.cs MyWebPart.cs

Compile complete -- 0 errors, 0 warnings
RenamedWebPart -> C:\myprojects\RenamedWebPart\bin\Debug\RenamedWebPart.dll
Starting sequence of Retract/Delete/Build/Install/Deploy
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe" -o retractsolution -name RenamedWebPart.wsp -immediate -allcontenturls

Timer job successfully created.

"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe" -o execadmsvcjobs

Executing .
Executing solution-deployment-renamedwebpart.wsp-0.
The solution-deployment-renamedwebpart.wsp-0 job completed successfully, but could not be properly cleaned up. This job may execute again on this server.
Operation completed successfully.

"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe" -o deletesolution -name RenamedWebPart.wsp

Operation completed successfully.

"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe" -o execadmsvcjobs

Executing .
Operation completed successfully.

Refreshing Deployment Files...
"C:\myprojects\stsdev.exe" /refresh RenamedWebPart C:\myprojects\RenamedWebPart\

STSDEV - Simple Tools for SharePoint Developers
Refreshing Solution Package Files
Current Solution Name:
Current Solution Directory:
Refreshing deployment files...
Rebuilding DeploymentFiles\manifest.xml
Rebuilding DeploymentFiles\SolutionPackage.ddf
Deleting Solution Package File...
Building Solution Package (Debug Version)
"C:\Windows\System32\makecab.exe" /F DeploymentFiles\SolutionPackage.ddf /D CabinetNameTemplate=RenamedWebPart.wsp
Microsoft (R) Cabinet Maker - Version 5.2.3790.0
Copyright (c) Microsoft Corporation. All rights reserved..

Parsing directives
Parsing directives (DeploymentFiles\SolutionPackage.ddf: 1 lines)
21,912 bytes in 7 files
Executing directives
0.00% - manifest.xml (1 of 7)
0.00% - RenamedWebPart.dll (2 of 7)
0.00% - RenamedWebPart\feature.xml (3 of 7)
0.00% - RenamedWebPart\WebParts.xml (4 of 7)
0.00% - RenamedWebPart\WebParts\CopiedPart.webpart (5 of 7)
0.00% - RenamedWebPart\WebParts\MyWebPart.webpart (6 of 7)
0.00% - IMAGES\RenamedWebPart\AfricanPith32.gif (7 of 7)
100.00% - IMAGES\RenamedWebPart\AfricanPith32.gif (7 of 7)
0.00% flushing current folder
92.06% flushing current folder
6.90% flushing current folder
100.00% flushing current folder
Total files: 7
Bytes before: 21,912
Bytes after: 4,362
After/Before: 19.91% compression
Time: 0.09 seconds ( 0 hr 0 min 0.09 sec)
Throughput: 237.76 Kb/second
Installing Solution...
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe" -o addsolution -filename DeploymentFiles\RenamedWebPart.wsp

Operation completed successfully.

"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe" -o execadmsvcjobs

Executing .
Operation completed successfully.

Deploying Solution...
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe" -o deploysolution -name RenamedWebPart.wsp -immediate -allowgacdeployment -allcontenturls

Timer job successfully created.

"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe" -o execadmsvcjobs

Executing .
Executing solution-deployment-renamedwebpart.wsp-0.
Operation completed successfully.

========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
Feb 22, 2008 at 2:43 AM
Deactivate and then activate the feature. I would also recommend, while the feature is deactivated, to delete the MyWebPart.webpart from the Site's web part gallery. When the feature is activated the MyWebPart.webpart and your other webpart files should become available in the site's webpart gallery.