in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Team Eli's blog

TeamEli's first CodePlex Project -- GUI to Add Solutions to SharePoint Solution Store

Well, I finally took the time to sit down and put together a CodePlex project for some of the application pages (ok...only one so far...) that I am building for SharePoint admins.  So far, I have an application page that allows SharePoint admins to upload SharePoint solutions into the solution store.  This gets rid of the need to have to log into the server to run that one pesty stsadm command (addsolution).  I am not sure if anybody will find this useful but I figured it would be a nice start for my presence on CodePlex.

TeamEli SharePoint (2007) Tools

 As far as the application goes, it's fairly straight forward.  A custom application page that resides in the ADMIN folder with a custom action on the operations page right underneath the Solutions Management link.  Turns out it is pretty easy to add new solution files to the store.  First, I have to save a copy of the file locally so that the API can access the file then I check to see if the solution already exists.  If it does, it upgrades the solution.  Otherwise, it just adds the solution to the store.

// Saves file to local system so that sharepoint can upload it
string path = "C:\\Packages\\" + upload_Solution.FileName;
upload_Solution.SaveAs(path);

// Gets current solution (if present)
SPSolution solution = SPFarm.Local.Solutions[upload_Solution.FileName];

if (solution == null)
{
     
// Adds new solution to farm
     
solution = SPFarm.Local.Solutions.Add(path);
}
else
{
    
if (solution.Deployed)
     {
          
// Upgrades the solution now.
          
solution.Upgrade(path, DateTime.Now);
     }
    
else
    
{
         
// Removes solution and re-adds it
         
solution.Delete();
          solution =
SPFarm.Local.Solutions.Add(path);
     }
}

Please feel free to give it awhirl and let me know what your thoughts are and if you have any problems.

Eli

Comments

No Comments

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts