0

I am using powershell to update and deploy solutions

UpdateSolution.ps1

Add-SPSolution -Identity SomeWP.wsp -LiteralPath $PSScriptRoot\SomeWP.wsp -GACDeployment
Add-SPSolution -Identity SomeWP.wsp -LiteralPath $PSScriptRoot\SomeWP.wsp -GACDeployment

Deploy Solution.ps1

param([string]$workspaceUrl)
[Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges(
{
Install-SPSolution –Identity SomeWP.wsp –WebApplication $workspaceUrl –GACDeployment -Force
Install-SPSolution –Identity SomeWP.wsp –WebApplication $workspaceUrl –GACDeployment -Force
}
)

Now if I run Update.ps1 and wait for sometime and then run Deploy.ps1, it works fine, but if I run them one after the other it says

Install-SPSolution : A deployment or retraction is already under way for the solution "someWP.wsp", and only one deployment or retraction at a time is supported.

Now how can I automate this? like once the update is complete, I want to run deploy automatically

4
  • 1
    Is there some reason you need to run Install-SPSolution on the same WSP you just updated? To my understanding, that is redundant. Update-SPSolution will update a WSP "live", so to speak, and it will remain deployed (but now updated). You would only need to run Install-SPSolution if you had retracted and removed the WSP, which you bypassed by running Update-SPSolution in the first place. Jul 13, 2016 at 13:29
  • oh okay. I was not aware of it, thought it should be deployed after updating So I need to perform install only if I add solution? Jul 13, 2016 at 13:31
  • 1
    Yes, exactly. If you add a new solution with Add-SPSolution then you need to run Install-SPSolution to deploy it. But once it's deployed, Update-SPSolution is all you need. Jul 13, 2016 at 13:33
  • Addressing your edit: have you actually tried it this way? Previously, you were running Install after Update, but Update causes a re-deployment of the solution, which is why you would get the error "A deployment...is already underway". Add does not trigger a deployment (which is why you have to run Install after it), so you may not get the same error.... Jul 13, 2016 at 14:31

1 Answer 1

0

I have good success using powershell DSC to install and update solutions. For example this block install and deploys the solution.

SPFarmSolution appointment.workflow.v.1.0.0.wsp
        {
            Name                  = "appointment.workflow.v.1.0.0.wsp"
            LiteralPath           = "path to solution"
            Ensure                = "Present"
            Version               = "1.0.0"
            WebApplications       = @("https.dev.com")
            Deployed              = $true
            PsDscRunAsCredential  = $Script:FarmAdmin
        }

To remove, change "deployed" to false and Ensure "Absent". I have used this method to update custom solutions across several dozen farms.

The workflow: The solution is updated and the version number is changed. Solution is uploaded to DSC Pull server DSC Script is run to uninstall old solution Script is updated to install new solution New script is then run

It has worked pretty well for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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