Answered by:
"Clickable" Deployment of Webpart

Question
-
Hello everybody
My boss came in my office and five minutes later I was a SharePointExpert and have to deliver a webpart....
The goal is to have a file (wsp, cab or something else) our customer can load into SharePoint 2007.
***************************
Question one:
Is it possible to have just a simple file with all dlls, pics and config data in it which the SharePoint admin can load via GUI (click click) and there are no command line commands to enter and no involved Visual Studio deployment functionality?
If yes is there a sample to build this from a to z?
***************************
Question two:
Of course I tried things before I ask here and stumbled upon STSDEV. This creates a deployable "Solution" and as far as I have understood the generated files, it deploys the WebPart as a feature. Is it possible to deploy a webpart as a feature? I ask because the well documented (even with video) project generates an error in SharePoint (see below):
The error claims that the .webpart file is missing. But it is in the package.
I have the impression that Sharepoint is not analyzing the delivered cab as solution but as something else (old format?).
***************************
Question 3
Description of the loading process I do:
Site Actions -> Site Settings
Then under "Galleries" I click "WebParts".
After clicking to "Upload" i enter the path to the generated cab (Company.OurWebParts.wsp.cab). I also tried renaming it to "Company.OurWebParts.wsp" did not help. This loads something. But the loaded item has not a XML-sheet icon but only an empty-sheet icon.
When I click on the icon of my webpart the error message below occurs.
Did I something wrong?
***************************
If anybody can enlighten me...many thanks
Best regards
Ben
***************************
Error message:
The file you imported is not valid. Verify that the file is a Web Part description file (*.webpart or *.dwp) and that it contains well-formed XML. at Microsoft.SharePoint.WebPartPages.WebPartImporter.CreateXdoc(XmlReader reader)
at Microsoft.SharePoint.WebPartPages.WebPartImporter..ctor(SPWebPartManager manager, XmlReader reader, Uri webPartPageUri, SPWeb spWeb)
at Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager manager, XmlReader reader, Boolean clearConnections, Uri webPartPageUri, SPWeb spWeb)
at Microsoft.SharePoint.WebPartPages.WebPartPreview.get_WebPart()
at Microsoft.SharePoint.WebPartPages.WebPartPreview.CreateChildControls()
at System.Web.UI.Control.EnsureChildControls()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
***************************
The file structure in the cab is:
IMAGES (dir)
-- Company.OurWebParts
-- logo.gif
Company.WebParts (dir)
-- WebParts (dir)
-- CustomWebPart2.webpart
-- CustomWebPart1.webpart
-- WebParts.xml
-- feature.xml
manifest.xml
Company.OurWebParts.dll- Edited by Santosh Kumar Nair Friday, June 26, 2009 5:41 PM fixing thread title bug
Friday, June 19, 2009 7:03 AM
Answers
-
As you mention in your post you can create a solution file, this is a WSP. It can be copied to the server and run STSADM commands (STSADM -O addsolution, STSADM -O deploysolution). Have you looked at WSPBuilder http://www.codeplex.com/wspbuilder. You can only deploy the .webpart file to the webpart gallery using a feature, you need the WSP to deploy the assembly to the GAC or bin folder of the web application and to add a safecontrol in the web.config. The .webpart file is provisioned using a <Module>, there's an example here http://msdn.microsoft.com/en-us/library/dd348394.aspx (scroll down to "creating the features").
Hope this helps
Dave
My SharePoint Blog - http://www.davehunter.co.uk/blog- Proposed as answer by Dave Hunter Monday, June 22, 2009 9:06 AM
- Marked as answer by Paul AndrewMicrosoft employee Tuesday, June 23, 2009 2:13 AM
Friday, June 19, 2009 8:34 AM
All replies
-
********************************
Addition:
I must say, I use Visual Studio 2005 even though I mentioned "no involved Visual Studio deployment functionality". I meant not pressing a "Deploy" button in VS.
********************************
Correction, the file structure in the cab is:
IMAGES (dir)
-- Company.OurWebParts(dir)
-- logo.gif
Company.OurWebParts (dir)
-- WebParts (dir)
-- CustomWebPart2.webpart
-- CustomWebPart1.webpart
-- WebParts.xml
-- feature.xml
manifest.xml
Company.OurWebParts.dll
********************************
manifest.xml
********************************
<?xml version="1.0" encoding="utf-8"?>
<!--Manifest created STSDEV utility at 19.06.2009 08:14:35-->
<Solution SolutionId="99993E67-DC25-4A75-ADD1-79DD9CFB706C" ResetWebServer="True" xmlns="http://schemas.microsoft.com/sharepoint/">
<!--Feature Manifest files-->
<FeatureManifests>
<FeatureManifest Location="Company.OurWebParts\feature.xml" />
</FeatureManifests>
<!--TEMPLATE files-->
<TemplateFiles>
<TemplateFile Location="IMAGES\Company.OurWebParts\logo.gif" />
</TemplateFiles>
<!--Assembly files-->
<Assemblies>
<Assembly Location="Company.OurWebParts.dll" DeploymentTarget="GlobalAssemblyCache">
<SafeControls>
<SafeControl Assembly="Company.OurWebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9999776d559ee183" Namespace="Company.OurWebParts" TypeName="*" Safe="True" />
</SafeControls>
</Assembly>
</Assemblies>
</Solution>
********************************
feature.xml
********************************
<?xml version="1.0" encoding="utf-8" ?>
<!-- Created by STSDEV at 18.06.2009 08:53:15
-->
<Feature Id="99996C13-7222-4444-8BFF-5E75E2057CA1" Title="A sample feature: Company.OurWebParts" Description="This SharePoint solution was created by the STSDEV utility (http://codeplex.com/stsdev)" Version="1.0.0.0" Scope="Site" Hidden="false" ImageUrl="Company.OurWebParts\logo.gif" xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="WebParts.xml" />
<ElementFile Location="WebParts\CustomWebPart1.webpart" />
<ElementFile Location="WebParts\CustomWebPart2.webpart" />
</ElementManifests>
</Feature>
********************************
WebParts.xml
********************************
<?xml version="1.0" encoding="utf-8" ?>
<!-- Created by STSDEV at 18.06.2009 08:53:15
-->
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="Company.OurWebParts" List="113" Url="_catalogs/wp" Path="WebParts" RootWebOnly="True">
<File Url="CustomWebPart1.webpart" Type="GhostableInLibrary">
<Property Name="Group" Value="Company.OurWebParts" />
</File>
<File Url="CustomWebPart2.webpart" Type="GhostableInLibrary">
<Property Name="Group" Value="Company.OurWebParts" />
</File>
</Module>
</Elements>
********************************
CustomWebPart2.webpart
********************************
<?xml version="1.0" encoding="utf-8"?>
<!--Created by STSDEV at 18.06.2009 08:53:15-->
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Company.OurWebParts.CustomWebPart2, Company.OurWebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9999776d559ee183" />
<importErrorMessage>Error importing Web Part 2</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title" type="string">Default title for CustomWebPart2</property>
<property name="Description" type="string">A demo Web Part created by stsdev</property>
<property name="ChromeState" type="chromestate">Normal</property>
<property name="AllowZoneChange" type="bool">True</property>
<property name="AllowHide" type="bool">True</property>
<property name="ExportMode" type="exportmode">All</property>
</properties>
</data>
</webPart>
</webParts>
********************************
CustomWebPart1.webpart
********************************
<?xml version="1.0" encoding="utf-8"?>
<!--Created by STSDEV at 18.06.2009 08:53:14-->
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Company.OurWebParts.CustomWebPart1, Company.OurWebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9999776d559ee183" />
<importErrorMessage>Error importing Web Part 1</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title" type="string">Default title for CustomWebPart1</property>
<property name="Description" type="string">A demo Web Part created by stsdev</property>
<property name="ChromeState" type="chromestate">Normal</property>
<property name="AllowZoneChange" type="bool">True</property>
<property name="AllowHide" type="bool">True</property>
<property name="ExportMode" type="exportmode">All</property>
</properties>
</data>
</webPart>
</webParts>Friday, June 19, 2009 8:02 AM -
As you mention in your post you can create a solution file, this is a WSP. It can be copied to the server and run STSADM commands (STSADM -O addsolution, STSADM -O deploysolution). Have you looked at WSPBuilder http://www.codeplex.com/wspbuilder. You can only deploy the .webpart file to the webpart gallery using a feature, you need the WSP to deploy the assembly to the GAC or bin folder of the web application and to add a safecontrol in the web.config. The .webpart file is provisioned using a <Module>, there's an example here http://msdn.microsoft.com/en-us/library/dd348394.aspx (scroll down to "creating the features").
Hope this helps
Dave
My SharePoint Blog - http://www.davehunter.co.uk/blog- Proposed as answer by Dave Hunter Monday, June 22, 2009 9:06 AM
- Marked as answer by Paul AndrewMicrosoft employee Tuesday, June 23, 2009 2:13 AM
Friday, June 19, 2009 8:34 AM -
Hello Dave
Thank you very much for the very good links...
I took the Company.OurWebParts.wsp.cab file from STSDEV and renamed it to Company.OurWebParts.wsp (without .cab)
Then I issued the following command line commands and it worked like a charm.
C:\> cd \Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN> stsadm -o addsolution -filename c:\temp\Company.OurWebParts.wsp
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN> stsadm -o deploysolution -name Company.OurWebParts.wsp -url "http://<server>:<port>" -immediate -allowgacdeployment
To be honest, I am a bit dissapointed. I mean we have 2009 and not 1985 with green text on black screens. Why is it not possible to just click the thing into sharepoint? Very annoying this cmd stuff. But that is just my taste. Others want everything on the command line. "One cannot do it right for all."
Thanks again
zuioplMonday, June 22, 2009 7:08 AM -
Hi Zuiopl,
SharePoint deployment has come along a long way. Before this you need to deploy files manually and to each web front end. The only packaged deployment has using a webpart package. SharePoint has a safe controls mechanism which means that it only allows code to be run which it trusts. WSPs allow you to deploy a webpart assembly to the GAC or bin folder, but you need to specify which webpart galleries you want the webpart to be avaiable, this gives you the "administrator" the level of control over your SharePoint environment. Otherwise end users would be able to add webparts from all the assemblies deployed even if they weren't part of the specific site.
Hope this helps
Dave
My SharePoint Blog - http://www.davehunter.co.uk/blog- Proposed as answer by Dave Hunter Monday, June 22, 2009 9:12 AM
- Unproposed as answer by Paul AndrewMicrosoft employee Tuesday, June 23, 2009 2:13 AM
Monday, June 22, 2009 9:12 AM -
There are several reasons why you use WSP's to deploy your SharePoint solutions, but sometimes you may think it's strange that there are no upload WSP file in the central admin - but without it the environment is more secure (only admins with local logon rights can add new solutions). When you deploy a WSP into your farm, these features/files/DLLs/resources will be distributed across the different virtual/physical servers and once you add a new one your WSP's will be deployed onto the new ones.
The only STSADM command you really need to use is the addsolution. Deployment can be done through Central administration (ops page), but with limitied configuration possibilities.
/WW
SharePoint Architect http://www.wictorwilen.se/Monday, June 22, 2009 10:49 AM -
Aha, a combination of history and security. Makes sense to me. The history thing I know too well from our own software.
Since I could reduce it to a single command like WW sayd. I can live with it.
Best regards again
zuioplTuesday, June 23, 2009 9:46 AM