WaitForJobToFinish issue when deployment is too quick


I seem to have a case where a solution deployment is so quick that by the time WaitForJobToFinish is called, Get-SPTimerJob returns a null job.

The solution simply deploys a library dll to the GAC, so I would imagine that deployment would be fast. Does my hypothesis sound correct?

I've update WaitForJobToFinish to log a warning rather than throw an exception when the job is not found, but I'm wary of this approach. While it works in my testing, I fear I may be missing something.


file attachments


rdurell wrote Oct 15, 2013 at 12:21 PM

It turns out that the issue was actually that length of the WSP filename was causing the WaitForJobToFinish to not find the timer job. The retraction job would be found, but the deployment job could not be found.

matein78 wrote Nov 10, 2013 at 8:32 PM

Thanks for getting back! And sorrz for the late reply.How long was your solution filename? Then I can check it out and handle it in the function.

tobey wrote Mar 12, 2014 at 8:04 AM

Hi!In my environment (SP 2010) for long solution names the deployment job name is cut off ("solution-deployment-mySampleVeryLongSolutionNa-") but the deployment job title is not ("Microsoft SharePoint Foundation Solution Deployment for "mySampleVeryLongSolutionName.wsp"").

Following change in WaitForJobToFinish seems to work for me:

$jobName = "solution deployment$solutionFileName*" #"solution-deployment$solutionFileName*" $job = Get-SPTimerJob | ?{ $_.Title -like $jobName } # ?{ $_.Name -like $jobName }

matein78 wrote Mar 12, 2014 at 8:02 PM

No reply, added info into thrown exception to report length of file name

** Closed by matein78 1/4/2014 3:02 PM

matein78 wrote Mar 12, 2014 at 8:03 PM

Thanks for the fix tobey, I will look into into for the upcoming release.

tobey wrote Mar 13, 2014 at 9:41 AM

I have to correct myself. Change should be:

$jobName = "solution deployment$solutionFileName*" #"solution-deployment$solutionFileName*" $job = Get-SPTimerJob | ?{ $_.Title -like $jobName } # ?{ $_.Name -like $jobName }

wuwu wrote Jun 13, 2014 at 1:27 PM

I get also this error. I tried the fix from tobey, but it is not working.
Here is my script part, what i changed at script SPSD_Deployment.ps1.
if(!$retract){ # Deployment / Update
                    $solution = Get-SPSolution -Identity $solutionName -ErrorAction:SilentlyContinue
                    # $jobName = "*solution-deployment*$solutionFileName*" 
                    $jobName = "solution deployment$solutionFileName*" 
                    # $job = Get-SPTimerJob | ?{ $_.Name -like $jobName } 
                    $job = Get-SPTimerJob | ?{$_.Title -like $jobName}
                    if ($job -eq $null) 
What did I made wrong, can somebody help me, thanks a lot!

Solution Name:

wuwu wrote Jun 13, 2014 at 1:29 PM

See my logfile at attachment at the top of forum entry.

Rickenberg wrote Jun 13, 2014 at 10:02 PM

Hi wuwu, I have tried to repro your issue on 2010 and 2013 but I can't. So the file name length is definetly not the issue here :-).

I'm a bit surprised that the error message you posted refers to two solutions: XXX.CoreResultWP.wsp and WAC.CoreResultWP.wsp...

Anyway, are you deploying the solution to many web applications or on a rather slow environment? I'm thinking that you might run into the timeout while deploying. You can either try to increase the DeploymentTimeout value in the config or if possible deploy the solution to fewer web applications by using a WebApplication element within the solution element in the config.

If that does not help I would like to have a look at the entire log file and your config.

Thanks, Bernd.

Rickenberg wrote Jun 13, 2014 at 10:10 PM

Just forgot to mention that you actually have two error messages in the posted log file.
You must provide a value expression on the right-hand side of the '-' operator.
It is related to issue #16809. You can fix this by downloading the latest version and at least update the SPSD_Extensions.ps1 in the scripts folder.

wuwu wrote Jun 14, 2014 at 6:51 AM

thanks for your anwser.
Sorry for the confusion. The solution is the same xxx.core... and wac.core...!
In the log at attachment you can see the whole error message and also the part, where the error ocure. The solution is retracted sucessfully and after deployed again, the error come up.
I will try to set the deployment time out a little bit higher.
For the other information, the other issue, it is the latest version, what i have downloaded.
Other ideas, what the problem could be?
I will try on monday the time out paramter.

Rickenberg wrote Jun 14, 2014 at 9:37 AM

I have published a new version last night for the 'other' issue. My guess is you are running with the that does not have the fix for the register-extension issue in PowerShell 2.0. Download the newest version and give it at go... Cheers...

wuwu wrote Jun 17, 2014 at 6:46 PM

Hello Rickenberg,
set up the value <WaitAfterDeployment>60000</WaitAfterDeployment> to 60000 is working for me.
I don't test the new version, just yet.
I will do this later.
Thanks for your help!

Rickenberg wrote Jun 17, 2014 at 8:08 PM

Great, good to hear that it helped!

tomek2k1 wrote Dec 9, 2014 at 3:21 PM

For multi-language support use the following fix:

$jobName = "solution-deployment$solutionFileName*"

$jobName = "$solutionFileName"

$job = Get-SPTimerJob | ?{ $_.Name -like $jobName }

$job = Get-SPTimerJob | ?{$_.Title -like $jobName}

tomek2k1 wrote Dec 9, 2014 at 3:23 PM

Sorry for double posting. I forgot to use the code tags. :(
# $jobName = "*solution-deployment*$solutionFileName*" 
$jobName = "*$solutionFileName*" 
# $job = Get-SPTimerJob | ?{ $_.Name -like $jobName } 
$job = Get-SPTimerJob | ?{$_.Title -like $jobName}

matein78 wrote Mar 16, 2015 at 7:34 PM

Thanks a lot for finding this out. Really odd indeed.
You could do a simple extension for SPSD which can be added to one event without customizing the actual base script. This way you are save with future updates.

Sample extensions can be found at here

I will try it out and see if I can reproduce the issue.