Editing contents of a WSP (SharePoint)

When deploying a new SharePoint feature for a trial upgrade 2010 environment, I was striking a problem with the contents of the WSP.  

Inconsequential to this story, there was a SYSTEM.WEB.DLL file within the WSP – and SharePoint 2010 would not allow it to be deployed (which is a good thing !)

clip_image002

My thinking was to just ‘remove’ the offending DLL from the WSP, and re-deploy.

WSP –> CAB File

In case you were unaware, you can see the contents of the WSP by changing the file extension to CAB.

You can then open the file like a ZIP file within Windows Explorer, or via WinRAR (my choice of zipper).

Can’t Update Contents

BUT – and this is the annoying bit – you CANNOT change the contents of the CAB file, and thus the contents of the WSP.   For a file type that is vital to the operation of SharePoint 2010, there is no way to simply modify the innards of a WSP file.

The preferred approach (?) is to open the WSP within Visual Studio 2010 – and/or Visual Studio 2008 along with WSPBuilder.   BUT – that’s not really a workable solution, when needing to do a ‘quick’ update – or modify the contents within a server environment.  

No, I’m NOT going to install Visual Studio on the server !!

The Problem

So – how do you do it ??    How do you delete a file from a WSP – and/or update the MANIFEST.XML file ?

From some fiddling, testing and trials – these don’t work :

  • Creating a new archive file within Windows Explorer – and changing to CAB or WSP extension
  • Trying to delete or drag into an archive shown in Windows Explorer
  • Creating a new archive with WinRAR – and/or dragging into a CAB file using WinRAR
  • Using MAKECAB.EXE to create an archive via command line
        • It’s just too fiddly & difficult
        • Need a DDF definition file to define the constructs – if needing to do more than ONE file (!)
        • And, the help files from Microsoft (for MAKECAB + CAB SDK) have been dropped/yanked
        • All other technical documentation in this area relates to MS-BUILD instead.
  • Try a different zipping tool (7-Zip), based on a recommendation from a work friend to create or edit CAB
  • Try yet another zipping tool (IZArc) – after another work friend said that he’d used it with success (?)

BUT – none of the above worked for me !

aaarrrrgggghhhh !!

About the only way that I could think of – and supported by suggestions from other work colleagues – was to use WSPBuilder and/or Visual Studio.

I’m staggered – and a little bit annoyed – that there is no decent tools for managing the contents WSP’s – especially given the importance (vitality !) for SharePoint 2010.  

If anyone knows of any such tools – then let me know – please !

The Solution :    Smile

I’m happy to report that there is one such zipper product (tool) that allows you to create a CAB archive – and then rename to be a WSP – and problem solved !   

It turns out I was sooo close to getting it sorted out – using IZArc – there’s a minor quirk which I’ll explain in a moment – but it definitely works !    Yay !

The steps involved to update the WSP are as follows :

  1. Rename the WSP to CAB
  2. Extract all contents to a folder – using Windows Explorer, or WinZip, WinRAR, or whatever
  3. Change the items you want, ie. MANIFEST.XML and remove a DLL (in my case)
  4. Create a new CAB file with the updated contents, using IZARC 
  5. Rename the newly created CAB to WSP
  6. Install to SharePoint

——————–

NB. I’m using a WSP for the SharePoint Reporting Services webparts – just as an example – RSWebParts.wsp

As mentioned, the first steps are to rename the WSP to CAB, and extract the contents to a folder.

You don’t HAVE to use IZArc for this step; you could do using WinZip, or WinRAR – or even the default Windows Explorer.

image

Next – go into the folder, and change whatever you need – such as DLL’s or XML’s, whatever.  

For this example, I’m going to remove the language sets for DE, ES, FR, IT (German, Spanish, French & Italian).   No reason – other than to ‘invent’ a change for this post – I don’t have anything against the European Union – honest !  

image

The next step is to create a new WSP – by re-CAB’ing these files – and here’s the trick that caught me out.

You may be tempted to simply do CTRL-A – and then RIGHT-CLICK > IZArc > ‘Add to Archive File’

But – this won’t allow you do sub-folders – I don’t know why !!

image

See…>    !?!!?

image

Instead – the steps you need to do are these :

  1. Open IZArc as a ‘program’
  2. Create a new archive
  3. Choose a CAB file type
  4. Add the files – and check the box for “subfolders”

——————–

So – let’s give it a go :

  • Click Start > LZArc
  • Click New
  • Give the new archive a name – eg. NewRSWebParts (can change it later)

image

The next window has two tabs – Selection – and Options

  • Firstly select all the files you need for the new WSP – in the Selection tab
  • I chose the folder and then did CTRL-A to select all the files needed

image

NEXT – switch to the Options tab >

  • Change the archive type to be “CAB”
  • Check the box for “Include sub-folders”
  • Click OK

image

After half a milli-second, you’ll have your new CAB file.

  • Can then click the big red “Exit” button – as we’re done with LZArc.
  • Switch back to Windows Explorer
  • Re-name the newly created CAB file –> WSP extension.

image

And – that’s it !

Only took a few steps to create a new WSP file – with updated contents – without needing Visual Studio – or WSP Builder !

Just remember that you might need to update your initial projects back in TFS, or Visual Studio anyway.

This is just for those emergency updates – or if you don’t have the source code/project.

Very nice indeed – very easy – and extremely useful !   

Nerd smile

Advertisements

17 thoughts on “Editing contents of a WSP (SharePoint)

  1. If you need to apply changes in a WSP package that is created using the Visual Studio 2010 SharePoint Tools you can do this by adding an AfterLayout target in the SharePoint project .csproj MSBuild file. In the AfterLayout target you get the LayoutPath value that points to the temp folder containing the WSP file contents and the manifest.xml file. You can add/remove files in this folder and modify the manifest.xml file.

    Have fun!

    Regards,
    Serge

    Like

  2. Thanks so much for this–I got frustrated with how tedious editing a wsp was a while back. There is a way to avoid the subfolder issue by creating the archive as a plain old zip and then using Tools > Convert Archive to output it to a cab file. I blogged about it here but the Convert Archive is all you really need to know.

    Like

  3. SharePoint list template files (.stp) are also comprised of a singular manifest.xml file compressed into a .cab and then the extension is changed to .stp

    I tried to modify some of the data that was saved into a particular .stp file that I had on hand, and then tried to re-compress the manifest.xml using the technique described above with IZarc. I then changed the extension back to “.stp”, but when I upload the file into my site’s List Templates, I get an error saying ‘manifest.xml not found’

    Would be interested to know if anyone else has encountered this.

    Like

      • I got that manifest.xml error reply when I re-CAB the files without looking at the full steps described above. If you just re-CAB them with RIGHT-CLICK > IZArc > ‘Add to Archive File’
        it won’t create the subfolders and that’s why it can’t find the manifest.xml. You have to do it as described above (or any other way that keeps the subolders structure) and you won’t have this problem.

        Like

  4. SharePoint did not like the WSP if I created a new CAB and added files to it. Clark’s method worked perfectly though. Extract original WSP files, make edits, add all files to new ZIP file, then open the ZIP with IZarc and choose Tools-Convert Archive to CAB. Renamed as WSP and upload/activation worked first try.

    Like

  5. Pingback: How To Create Bamboo Community Central As Top-Level Site « haiquangitvn

  6. or…. rename your file, to cab, extract manifest, update file and then Repackage the manifest.xml into a .CAB. Use the makecab.exe in the C:WindowsSystem32 folder by using the command prompt.

    Syntax: makecab.exe {workingfolder}manifest.xml {workingfolder}{template-name}.cab

    You could also just have it go straight to a stp with the following sintax:
    makecab.exe {workingfolder}manifest.xml {workingfolder}{template-name}.stp

    Like

  7. Thanks for this post. When I opened the CAB file,I did find two .webpart files. However, upon opening those, there was a tag but no child controls referenced. I’m accustomed to seeing user controls etc. in a visual web part along with a .aspx.cs file for managed code. How do I reverse engineer the .webpart files using the DLL included in the CAB file?

    Like

  8. Thanks so much for this post! After spending a few hours of trying to do WSP imports and rebuilds using VS2010 I almost gave up on saving my WSP. This did the trick and is VERY fast to rebuild and test site templates that have feature dependencies not available on target environments.

    Like

  9. Pingback: C/D/H Talks Tech » Fixing an invalid BCS column in a list template

  10. Pingback: SharePoint | J-SOLUTIONS BLOG SharePoint | Your Ticket to The Cloud

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s