Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS Build Definition Post Deployment Scripts Error When Executing Scripts

I have a TFS Build definition using the default template. The build completes on it's own but when I include a post deployment script I get the following error.

Exception Message: The directory name is invalid (type Win32Exception)
Exception Stack Trace: 
Server stack trace: 
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo     startInfo)
   at     Microsoft.TeamFoundation.Build.Workflow.Activities.InvokeProcess.ProcessWrapper.    Start()
   at     Microsoft.TeamFoundation.Build.Workflow.Activities.InvokeProcess.InvokeProcessIn    ternal.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.Func`2.EndInvoke(IAsyncResult result)
   at System.Activities.AsyncCodeActivity`1.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
   at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncC    odeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager     bookmarkManager)

The script itself is a powershell script that is included in the solution I'm trying to build and it only calls write-host messages. (for testing at this point)

The build definition has all the defaults selected with only the solution, post build arguments and post build script path changed. The script is checked into source control in the solution.

This is a POC environment so I have everything installed on the one server, so the TFS Server and Build Agents are on the same machine.

I've tried several workaround for this but none of them seem to be rooted around this particular error. Any help is much appreciated, thanks.

like image 898
Karl Schwirz Avatar asked Jul 27 '26 17:07

Karl Schwirz


1 Answers

(Coming from someone who recently encountered this issue themselves)

Check your "Source Settings" in the build definition.

  • Make sure you haven't cloaked the path to your script. That is, if you have your script in utilities/configuration, make sure you haven't cloaked utilities/
  • Your Build Agent folder should not use $(BuildDir), it should use $(SourceDir). Bear in mind this might change some paths in your script.

There is apparently a bug in the latest version of TFS that causes this hair-pulling issue. All the stuff about setting %WINDIR% in your Start-in directory for Powershell/Cmd etc. didn't work, but this did.

like image 56
AndyG Avatar answered Jul 30 '26 09:07

AndyG



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!