Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a base WSP and I would like to create an automated process to update one of the files that it contains (an XML file).

Is there anything in the Object Model that would allow me to do this? If not is there some way I could treat it as a CAB file and then modify the contents using standard .NET?

If I can't do either of the above, is it possible to recompile the project that creates the WSP through code and pass it a parameter that would implement the change?

share|improve this question
    
Can you elaborate - are you looking to update something after packaging and before deployment (e.g. a version number or something)? –  Ryan Nov 28 '11 at 9:20
    
I have an XML file that I plan on putting a license key into. Basically I am making an application that will generate the key, update the xml file and then email out the wsp to whoever purchased the key. –  Abe Miessler Nov 28 '11 at 16:51
    
Abe, why don't you use a separate xml file for that? Simple upload the licence file via web UI or via configuration/deployment script later. That's exactly how Nintex does. Why not? –  avishnyakov Jun 20 '12 at 3:44
add comment

4 Answers

Given that you're updating an XML file with a License Key this is what I would do.

(realise that a .wsp is just a renamed .cab file and that most zip software can unzip cab as well).

  • Use the EXPAND cmd line tool to unpack the .wsp to a local folder

(EDIT - Cabinet SDK and Expand tool no longer available. Instead use 7-Zip and http://ddfgenerator.codeplex.com/ - see bottom link)

  • Change the .xml file using whatever method appropriate
  • Rebuild the .wsp file using MAKECAB

KB176810 - How To Manually Modify and Rebuild CAB Files

Rebuilding a .WSP File in 4 Easy Steps

share|improve this answer
    
Have you tried this yourself? I was exploring this possibility before but I came across this post: sharepointroot.com/2010/07/07/… which seems to suggest that modifying a WSP in this way is not easily done. I haven't tried it myself though... –  Abe Miessler Nov 28 '11 at 18:09
    
Yes - its fiddly to get right but by no means impossible. –  Ryan Nov 29 '11 at 11:37
    
Sweet, I'll give this a shot. –  Abe Miessler Nov 29 '11 at 16:24
    
Turns out I somehow had a copy of expand which I can't find any more (this is part of the withdrawn makecab sdk) - for alternative see "Rebuilding" link which has copy of DDF generator on codeplex –  Ryan Nov 30 '11 at 16:59
add comment

You could use the WSPBuilder project from codeplex (http://wspbuilder.codeplex.com) to open up the WSP and modify any of the consisting files. WSPs can be opened up, modified and repackaged through the command line. More details at: http://www.itmonotony.com/Lists/Posts/Post.aspx?ID=40

share|improve this answer
    
Welcome to SharePoint.SE! We require relevant answers and disclosure of any affiliation with products or websites. Please see May I promote products or websites I am affiliated with here? for guidelines. –  Kit Menke Jun 20 '12 at 22:07
add comment

You dont specify the business case behind your requirement, but it sounds like something i would use web part adder for.

With this little known gem you can provision web parts dynamically, essentially as if you had several xml webpart files.

Read more in Wictor Wilen's blog post series on the subject.

share|improve this answer
    
Basically I have an XML file that I plan on putting a license key into. I am making an application that will generate the key, update the xml file and then email out the wsp to whoever purchased the key. –  Abe Miessler Nov 28 '11 at 16:52
    
With web part adder you could Have a central key repository instead, this would probably give you more control. If you go the xml way, you will probably want to disable export or at least protect the license key against being exported –  Anders Rask Nov 28 '11 at 17:38
    
The application that will be modifying the WSP will not be a SharePoint application. Just a standalone ASP.NET web application. Would this solution still work? –  Abe Miessler Dec 11 '11 at 5:04
    
Did you read the blog posts i mentioned? You are not modifying WSP's at all, you are using code and (for example) a data source of some kind to dynamically populate a web part group. –  Anders Rask Dec 11 '11 at 18:42
    
I'm a little confused about what you are saying. I did read the post you mentioned. When you say "You are not modifying WSP's at all" are you saying I don't NEED to modify a WSP in order do what I am trying to acheive? As it is right now I am definitely modifying a WSP. –  Abe Miessler Dec 11 '11 at 19:41
show 1 more comment

Blockquote I have a base WSP and I would like to create an automated process to update one of the files that it contains (an XML file).

Okay, as far as I saw prev posts, I would recommend to separate licence file and build up a web interface or bat/powershell script to setup licence file later. Exactly like Nintex workflow or other products does.

Personally, I don't think modifying wsp package is a appropriate strategy in that case.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.