I asked this question here before and didn't get a usable answer and I see other people are getting the same issue. I did some more testing, added a timer/t to my scripts and discovered that the Install-SPSolution / Uninstall-SPSolution always takes exactly8 hours to the minute to complete, no matter when I start it. I verified this over several refreshes of my webpart and it is always exactly 8 hours. This applies to both Central Admin and farm solutions. I hope that the duration of 8 hours to the minute does contain a clue to solve this issue.
This is the PS1 script I use to install the CA component:
param([string]$cadmin2010 = "", [string]$cadmin2013 = "")
Write-Output "Installing MySolution.CentralAdmin.wsp webpart"
Add-PsSnapin Microsoft.SharePoint.PowerShell
Write-Output "Loaded SharePoint environment"
$cadmin = $cadmin2010
if ($cadmin2013) {$cadmin = $cadmin2013}
Write-Output $("Installing webpart on " + $cadmin)
$sln = Add-SPSolution MySolution.CentralAdmin.wsp
Write-Output "Added solution"
Install-SPSolution -Identity MySolution.CentralAdmin.wsp -GACDeployment -Force
Write-Output "Installing solution"
while($sln.JobExists)
{
start-sleep -s 5
}
Write-Output "Solution installed"
Enable-SPFeature -Identity b2ff3a66-0f9d-4b4a-9b79-842aeca34d42 -url $cadmin -Force
Write-Output "Feature enabled"It takes 8 hours before the "Solution Installed" message is printed. Once it completes, everything works fine, but with the uninstall of an old version and the install of a new version, 16 hours is a long wait. This is the output of my script:
C:\Program Files\Product\EFS>RefreshCAComponents.cmd C:\Program Files\Product\EFS>time/t 04:55 PM C:\Program Files\Product\EFS>"C:\Windows\System32\WindowsPowershell\v1.0\powershell.exe" .\RemoveCaComponents.ps1 -cadmin2013 http://productionwfe1:6101/ Removing MySolution.CentralAdmin.wsp CA Customization Loaded SharePoint environment Removing CA Customization from http://productionwfe1:6101/ Disabled feature Uninstalled feature Uninstalling solution Solution uninstalled <-- takes 8 hours since printing the previous line Solution removed C:\Program Files\Product\EFS>time/t 12:55 AM C:\Program Files\Product\EFS>"C:\Windows\System32\WindowsPowershell\v1.0\powershell.exe" .\InstallCaComponents.ps1 -cadmin2013 http://productionwfe1:6101/ Installing MySolution.CentralAdmin.wsp webpart Loaded SharePoint environment Installing webpart on http://productionwfe1:6101/ Added solution Installing solution Solution installed <-- takes 8 hours since printing the previous line Feature enabled C:\Program Files\Product\EFS>time/t 08:55 AM