Geeks With Blogs

News





The SharePoint Hillbilly Fewer Big Words... More Pretty Pictures...

If you know me by now, you know that I’m a lazy man. I’ll spend 3 hours trying to find a better way to do work that would only take me 1/2 an hour if I just sat down and did it. Hmmm… maybe I’m not lazy, maybe I’m just determined.  Yeah… that probably sounds better on a resume… so.. if you know me by now, you know I’m a determined man… if I think there should be a better way to do something, I’ll find it.  See… that sounds so much better than lazy…

So, here was my current problem. I downloaded a WSP file (SharePoint Solution File for you lay persons). It’s not important what the WSP did… It did something I needed it to do.. okay? Anyway, I deployed the WSP… the skies opened up… sun shined… sun shown… sun rays fell from the sky… angels sang… life was good…

Or was it? Ugh.. I did not like that one view… it only showed 5 items in a list at a time (and I had 20,000 items to view). However, this wasn’t just a view on a list so I couldn’t edit the page, or modify the view.  Again, don’t worry about why I couldn’t do that. I just couldn’t… okay?  The angels shut up.. clouds covered the sky.. blah.. blah.. blah…

So, this stinkin view that I couldn’t edit in SharePoint or SPD only showed 5 rows at a time and I need to browse through 20,000 entries? That’s a show stopper right there….  or was it?

So.. brilliant idea… lets crack open the WSP file, modify the view (it was just an ASPX page) and redeploy the Solution? Sounds rockin right? Okay… not so fast. If you have ever tried to extract a file from a WSP you’ve found it’s super easy.  However, if you’ve ever tried to add the file back to the WSP (or CAB) you soon realize it’s not possible.

Worse yet, if you just rename a WSP file to CAB so that you can explore it in Windows I don’t think there is a way to extract out the directory structure. So, I’m left with a mess. If I want modify a file in a WSP file I have to follow these steps:

  1. Rename WSP file to CAB and extract all the files
  2. Modify the necessary files
  3. Rebuild the correct directory structure for the solution
  4. Copy the files into that directory structure (in the right place)
  5. Create a DDF file indicating name and location of all files to be in WSP file
  6. Run MakeCab using created DDF file to create cab, then rename cab to WSP

Sound about right? None of that is too difficult, it just sounds like a lot of garbage to go through when all I want to do is modify ONE stinking little file and re-deploy.  So, I posted the question on Twitter and started quite the discussion.  From all the responses I was actually able to put together a very quick method for extracting and rebuilding WSP files. (Thanks to @ChrisO_Brien, @davidfrette, @coreyroth, @tigertoy, @rhabridge, @RemyMaza, @BrianTJackett, @sympmarc, and @SharePoint Ninja for the discussion and Help). So, would you like to know the solution??? Hear it goes…

1. Extract WSP using 7 Zip

7 Zip is a free tool that will allow you to extract your WSP files AND the directory structure it was built with. There are probably other zip tools that will do this as well, I was just not able to do it with Windows. Regardless, use a tool that let’s you extract the files and directory structure from the WSP file. 

2. Modify your files

Okay, now go in and modify the files you need to modify. Make whatever changes you need to make. Be VERY careful if messing with the XML files though…all kinds of nastiness there if you screw something up.

3. Download and use DDFGenerator from CodePlex

So, my new friend on Twitter @tigertoy pointed me to a project on CodePlex called DDFGenerator.  It’s simply an executable. All you have to do is download this executable, execute it from the command line and give it the Path to the directory structure created by 7 Zip (or whatever program you used). This will generate your DDF file for you.

One quick note, the DDF Generator does not put an entry in the DDF to set the WSP file name. So, make your life easier, open up the .DDF file and add the following line along with the ther .Set lines:

.Set CabinetNameTemplate=SolutionName.WSP

This will make sure your WSP file is named properly with the correct extension. If you don’t do this it will create a cab file called “1.cab” when you run MakeCab.exe in the next step and you will have to rename it to your solution name. Not a big deal, just something to keep in mind.

4. Run MakeCab to create .CAB File

Now all you have to do is run MakeCab to generate your WSP file using the DDF you generated. This also will be run from the command line and will look something like:

MakeCab.exe /F

After you run the above command, you will have your WSP file which you can go deploy… watch the skies open again… yadda.. yadda.. yadda…

Thanks again for all those who helped with this today. Even though it is a four step process, it is a very QUICK four step process. By far the easiest solution I have found so far. That does NOT mean there is not a better one.. if you have one, I’d love to hear it.

Thanks again!

Posted on Tuesday, February 16, 2010 4:25 PM | Back to top


Comments on this post: Rebuilding a .WSP File in 4 Easy Steps

# re: Rebuilding a .WSP File in 4 Easy Steps
Requesting Gravatar...
My preference is to use WSPBuilder and SharePoint Installer to do development. It takes a little bit of setup work, but speeds up my development process greatly.

http://www.codeplex.com/wspbuilder
http://www.codeplex.com/sharepointinstaller

For production, I still use WSPBuilder, but my SharePoint admin prefers to use stsadm commands to install.

KD
Left by Ken Duenke on Mar 04, 2010 11:06 AM

# re: Rebuilding a .WSP File in 4 Easy Steps
Requesting Gravatar...
This is just what I needed. Thanks! I was struggling with the error, "Cannot find this file specified in the manifest file" for like an entire day until I found this.
Left by anon on Apr 16, 2010 10:34 AM

# re: Rebuilding a .WSP File in 4 Easy Steps
Requesting Gravatar...
Thanks a lot for that Information. I was having nightmares with my wsp and modifying the manifest.xml file in that. This article really did the magic for my issues. After 2 days of Googling I got what I wanted.

Thanks again.
Left by sudhee on May 13, 2010 5:13 PM

# re: Rebuilding a .WSP File in 4 Easy Steps
Requesting Gravatar...
Thanks a Lot
Left by Saminda on Jun 18, 2010 4:30 AM

# re: Rebuilding a .WSP File in 4 Easy Steps
Requesting Gravatar...
Maybe it would be best to use lower case letter when specifying the package name in ddf file. stsadm complains about the file extension in some cases if upper case is used.

Set CabinetNameTemplate=SolutionName.wsp
Left by Onsel Akin on Aug 06, 2010 6:32 AM

# re: Rebuilding a .WSP File in 4 Easy Steps
Requesting Gravatar...
Excellent!!! i was looking for some thing like this

Regards
Ram Kiran
Left by Ram Kiran on Nov 12, 2010 12:30 PM

# re: Rebuilding a .WSP File in 4 Easy Steps
Requesting Gravatar...
Many thanks.
Left by Hugo on Dec 14, 2010 2:28 PM

# re: Rebuilding a .WSP File in 4 Easy Steps
Requesting Gravatar...
It didnt work for me eventhough i got the ddf file.while try to run the MakeCab ,i got 4 errors which says files mentioned in the ddf files couldnt found
Left by rijuv on Jul 15, 2011 6:16 AM

Your comment:
 (will show your gravatar)


Copyright © Mark Rackley | Powered by: GeeksWithBlogs.net