I’ve modified a custom build process template to execute Powershell on the build server. This is so I can run some scripts that will automate the deployment of our SharePoint solution. Everything was working fine up until I upgraded the build servers Powershell version from 2.0 to 3.0 (which needed to be done as I was installing SCVMM Admin Console 2012 and Powershell 3.0 was a pre-requisite).
In the build template itself, I’m using a Microsoft.TeamFoundation.Build.Workflow.Activities.InvokeProcess work flow item to execute the PowerShell command with the following properties:
Arguments : String.Format(” “”& ‘{0}’ -DropLocation ‘{1}’ {2} “” “,
ScriptFilename, BuildDetail.DropLocation, PostDropScript2Arguments)FileName : “powershell”
OutputEncoding :
System.Text.Encoding.GetEncoding(System.Globalization.CultureInfo.InstalledUICulture.TextInfo.OEMCodePage)
Now every time I try to execute the build, I get the following error:
Exception Message: File not found: PowerShell (type
FileNotFoundException) Exception Stack Trace: Server stack trace:
at
Microsoft.TeamFoundation.Build.Workflow.Activities.InvokeProcess.ProcessWrapper.Start()
at
Microsoft.TeamFoundation.Build.Workflow.Activities.InvokeProcess.InvokeProcessInternal.RunCommand(AsyncState
state) at
System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr
md, Object[] args, Object server, Object[]& outArgs) at
System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage
msg, IMessageSink replySink)Exception rethrown at [0]: at
System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message
reqMsg, Boolean bProxyCase) at
System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed,
MessageData& msgData) at System.Func2.EndInvoke(IAsyncResult1.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext
result) at
System.Activities.AsyncCodeActivity
context, IAsyncResult result) at
System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor
executor, BookmarkManager bookmarkManager)Inner Exception Details:
Exception Message: The system cannot find the file specified (type
Win32Exception) Exception Stack Trace: at
System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo
startInfo) at
Microsoft.TeamFoundation.Build.Workflow.Activities.InvokeProcess.ProcessWrapper.Start()
It seems like the build is no longer able to link the “powershell” command with the actual PowerShell file.
I’ve manually gone onto the build server and typed “powershell” into a command line and it started PowerShell, as expected.
Has anyone else experienced this issue before?
Thanks very much
Add the full filepath to powershell.exe in the invokeprocess step in your workflow and it should always work (I would not trust the environment-settings for this)
And know, logging in on the server under your own account is not equal to the build server running under a specific account.