none
Update-SPSolution vs. SPSolution.Upgrade() - Issue when deploying on farm

    Question

  • Hello,

    I have a SharePoint site on a farm with 3 servers.  I usually update the farm using SPSolution-Update in management shell. If you run SPSolution-Update on any server in the farm, it correctly updates all servers in the farm. Recently I wrote a console app in C# that updates the solution without having to use SP Management Shell.  It basically saves the .wsp file to a temp folder, and then calls Upgrade(path) on the SPSolution.

    SPSolution solution = SPFarm.Local.Solutions["SolutionName.wsp"];
    solution.Upgrage([path to .wsp file]);

    This works fine in the development and test environment, where there are only 1 server per farm.  However, in production, it ONLY updates the server that the app runs on.  If I run the app on each server in the farm, all is good. However I want to be able to just run it on 1 server in the farm, like you can with Update-SPSolution.

    Any idea on what I need to do?

    Thanks,
    Justin

    Saturday, August 25, 2012 3:20 PM

Answers

All replies

  • Hello,

    Update-SPSolution cmdlet uses SPSolutionDeploymentJob to update solution on each front end. Unfortunately SPSolutionDeploymentJobDefinition class is internal so you can't use it, but you should do something similar to that. So I would propose to create timer job that will execute upgrade code on each frontend:

    http://msdn.microsoft.com/en-us/library/ff464297.aspx

    Monday, August 27, 2012 11:33 AM
  • In fact, use the overload SPSolution.Upgrade with the param DateTime. This runs the internal upgrade method that creates a timer job!

    Internal code:

    // Microsoft.SharePoint.Administration.SPSolutionLanguagePack
    internal void Upgrade(string path, DateTime dt, bool isRestore)
    {
        this.UpgradeCabFile(path, isRestore);
        this.DeleteExtractedFiles();
        this.CreateSolutionDeployTimerJob(dt, null, SPSolutionDeploymentJobType.Upgrade, falsetrue, isRestore, null);
    }

    Wednesday, February 06, 2013 4:10 PM