0
votes

I am trying to run an (empty) batch file from a customized TFS Build Definition, but every time the process hits the "Run Script" build activity, I get a "Directory Name is invalid" error.

We are using TFS 2013 Update 4 on Windows Server 2008 R2 Standard, and I am running Visual Studio 2013 from a Win 8.1 Pro on my dev machine.

The batch file in question is at "C:\Builds\SP_Base" on the TFS Server (as shown in the test condition in my customized build template. Here's the template itself (based on GitTemplate.12.xaml, since we are using Git as our source control):

enter image description here

This is the definition for our "Run Script" action: enter image description here

From the log file, we can see that the test for the directory with the batch file passes without an issue. The same log file then shows the error:

enter image description here

Does anybody know how to resolve this, please?

I've seen other threads discussing the "directory name invalid" issue in other contexts, and the closest match was the one referring to the fact that cmd.exe gets invoked without sufficient privileges.

If we are looking at a symptom of a similar issue here, then what should I do to invoke cmd.exe from a TFS build process without errors?

Currently this is what I have if I look at cmd.exe's properties:

enter image description here

1
Modifying the build process template is almost never a good idea. What are you doing in that script that you can't do in a Pre-Build script?Daniel Mann
We need to run several legacy batch files to compile and build a number of non-.NET projects. This should be introduced as the only addition to the original build template.Victoria

1 Answers

0
votes

In answer to my question about how to invoke cmd.exe from TFS build process...

I found I can use InvokeProcess activity instead of RunScript in my customized build template. This article helped.

This is my new custom template xaml (including error handling for InvokeProcess): enter image description here

Also, having added variables ExitCode (Int32) and ErrorMessage (String) as per article, the properties of the InvokeProcess activity now look as follows:

enter image description here

Please note the leading "/c" term in Arguments property for InvokeProcess. Without it, the activity will run and return no error, but the script will not get executed.

Hope this helps somebody with a similar issue.