U2U Blog

for developers and other creative minds

Deploy a SharePoint Solution Programmatically

A lot of you are familiar with the new solutions story within Windows SharePoint Services 3.0. In short, you package your solution components (assemblies, features, …) together with a manifest file into a SharePoint solution file (represented by a wsp file). Next, you can add the SharePoint solution to the solution store (typically using stsadm) and the using the SharePoint 3.0 Central Administration, you can deploy it to one of the available site collections either locally or on front-end Web Servers or application servers.

All of this is also exposed in the object model. I am currently finishing an MSDN article titled 'SharePoint Development Tools and Techniques for Creating, Packaging, Deploying, and Maintaining Code' and I have included some discussions on all of this. As a small teaser, here are the steps how you can add a solution to a solution store and deploy it to a site collection using C# code assuming you deploy everything on a local machine.

// -- adding the solution to the solution store
SPSolution solution = SPFarm.Local.Solutions.Add(@"C:\Packages\HelloWebPart.wsp");

// -- deploying the solution to a site collection
Collection<SPWebApplication> webapps = new Collection<SPWebApplication>();
SPWebApplication webapp = SPWebApplication.Lookup(new Uri("http://wss.litwareinc.com"));
webapps.Add(webapp);
solution.DeployLocal(true, webapps, true);

The assembly you need to reference is the Microsoft.SharePoint.dll and the namespaces used here are Microsoft.SharePoint.Administration and System.Collections.ObjectModel.

Have fun!

Comments (19) -

  • web links

    6/28/2015 1:26:01 AM | Reply

    Aw, this was a really nice post. In idea I would like to put in writing like this additionally – taking time and actual effort to make a very good article… but what can I say… I procrastinate alot and by no means seem to get something done.

  • mansion88

    7/1/2015 2:08:33 PM | Reply

    You should take part in a contest for one of the best blogs on the web. I will recommend this site!

  • free index

    7/13/2015 11:09:38 AM | Reply

    This really answered my problem, thank you!

  • büyü,muska

    9/7/2015 4:21:21 PM | Reply

    Oh my goodness! an amazing article dude. Thank you However I am experiencing issue with ur rss . Don’t know why Unable to subscribe to it. Is there anyone getting identical rss problem? Anyone who knows kindly respond. Thnkx

  • COMINT

    9/13/2015 3:39:04 PM | Reply

    Would you be interested in exchanging links?

  • spor bahisi

    9/16/2015 10:06:46 AM | Reply

    you have a great blog here! would you like to make some invite posts on my blog?

  • Babysitting jobs

    9/18/2015 4:10:52 AM | Reply

    I’d have to check with you here. Which is not something I usually do! I enjoy reading a post that will make people think. Also, thanks for allowing me to comment!

  • authority source

    9/30/2015 11:04:36 AM | Reply

    You should take part in a contest for one of the best blogs on the web. I will recommend this site!

  • brisbane cosmetic surgeon

    10/2/2015 3:12:27 PM | Reply

    An impressive share, I just given this onto a colleague who was doing a little analysis on this. And he in fact bought me breakfast because I found it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love reading more on this topic. If possible, as you become expertise, would you mind updating your blog with more details? It is highly helpful for me. Big thumb up for this blog post!

  • free index

    10/15/2015 3:19:13 PM | Reply

    you have a great blog here! would you like to make some invite posts on my blog?

  • green card lawyer

    10/21/2015 6:33:09 AM | Reply

    Can I just say what a relief to find someone who actually knows what theyre talking about on the internet. You definitely know how to bring an issue to light and make it important. More people need to read this and understand this side of the story. I cant believe youre not more popular because you definitely have the gift.

  • web directory

    10/21/2015 9:35:59 PM | Reply

    When I originally commented I clicked the -Notify me when new comments are added- checkbox and now each time a comment is added I get four emails with the same comment. Is there any way you can remove me from that service? Thanks!

  • FCPX Effects

    11/6/2015 2:41:49 PM | Reply

    There is noticeably a bundle to know about this. I assume you made certain nice points in features also.

  • m88

    11/12/2015 5:35:21 AM | Reply

    This really answered my problem, thank you!

  • sick

    11/24/2015 5:59:26 AM | Reply

    I discovered your blog site on google and check a few of your early posts. Continue to keep up the very good operate. I just additional up your RSS feed to my MSN News Reader. Seeking forward to reading more from you later on!…

  • Tall Tees

    12/7/2015 8:31:25 AM | Reply

    Can I just say what a relief to find someone who actually knows what theyre talking about on the internet. You definitely know how to bring an issue to light and make it important. More people need to read this and understand this side of the story. I cant believe youre not more popular because you definitely have the gift.

  • high quality backlinks

    12/11/2015 1:24:24 PM | Reply

    I discovered your blog site on google and check a few of your early posts. Continue to keep up the very good operate. I just additional up your RSS feed to my MSN News Reader. Seeking forward to reading more from you later on!…

  • iPhone Ad Blocker

    12/11/2015 8:31:17 PM | Reply

    The next time I read a blog, I hope that it doesnt disappoint me as much as this one. I mean, I know it was my choice to read, but I actually thought youd have something interesting to say. All I hear is a bunch of whining about something that you could fix if you werent too busy looking for attention.

Loading