SharePoint Solution Downloader

Special thanks to Djamel Chagour and his response to my MSDN thread (which linked to this blog post) to solve my issue of grabbing solutions from the Solution store so I could drop them on another server.

His post is more complex and deals with generating the stsadm commands for a batch deployment. Mine is the dumbed down version that just pulls the files so I can readd them as I need them.

Here's the code:



using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.IO;

using Microsoft.SharePoint;

using Microsoft.SharePoint.Administration;

using System.Xml;

using System.Web;



namespace Mirant.SharePoint.Administration.WSPDownloader

{

    class Program

    {

        static void Main(string[] args)

        {

            bool hasErrors = false;



            if (args.Length != 1)

            {

                Console.WriteLine("Usage: Company.SharePoint.Administration.WSPDownloader directory\r\n\tdirectory: full path on the local file system that you want the solutions downloaded to");

                hasErrors = true;

            }



            

            if (!hasErrors)

            {

                string path = args[0];

                path = path.Replace("\"", "");

                if (!path.EndsWith("\\"))

                    path += "\\";



      

                SPSolutionCollection solutions = SPFarm.Local.Solutions;



                foreach (SPSolution solution in solutions)

                {

                    SPPersistedFile wspFile = solution.SolutionFile;

                    wspFile.SaveAs(path + solution.Name);

                }

            }

             

        }

    }

}

Comments

Popular posts from this blog

ERROR: Failed to create feature receiver...

Renaming a Sharepoint 2007 / WSS 3.0 Server