Reputation: 3899
I have created a build definition on TFS 2013 and inside the process tab of build definition there are 5 sections for Build process parameter
Inside the Build section there are 5 sub section
Inside Advanced section there is an option of “pre-build script arguments” & “prebuild script path”.
Inside the “prebuild script path” I have provide the path of a batch file.
This batch file calls an exe file which is available at the same location. In batch file I have written below lines
start "My Project" MyProject.exe
MyProject.exe is a console application with below codes
string[] lines = { "First line", "Second line", "Third line" };
string fileName2 = DateTime.Now.ToLongDateString().Replace("//","_").Replace(",","_") + DateTime.Now.ToLongTimeString().Replace(":", "_").Replace(" ","") + ".txt";
System.IO.File.WriteAllLines(fileName2, lines);
Now I am running this TFS build application then it is taking too much time at pre-build event. It was running for last 50 minutes then I stopped it.
Before adding batch script build process was working fine.
Now my question is that how can I make sure that whatever I have written in batch script is running successfully and exe file is writing a *.txt file so where can I check that file?
I have gone through these links
Post build event in VS2012..Running a Batch file
Problem Executing Batch File in Pre-Build Event
But they are talking that their build is failing but in my case build is not failing rather that that it is taking too long time.
Sorry if this question is irrelevant or I am doing some mistake. I am new to TFS build integration and not much aware about all those processes.
Upvotes: 0
Views: 1975
Reputation: 3899
I am able to resolve my issue after going through the tips provided by stijn .
Below are the TIPS given by stijn. You can find the same in comments.
Don’t rely on the current working directory, that is nearly always bad practice. Instead use a full path (either hardcoded, or pass e.g. the project's directory as an argument to your exe) so at least you know where to find your txt file.
If your build hangs it is waiting for user input. Possibly your exe crashed and is showing a dialog to attach the debugger
If your batch file is really as shown, you don't need it: just call the exe directly.
You can add console output to your batch file/exe to check what's it doing, this should be output in TFS
Then I do the following things.
Still I was getting one issue that I was not able to create a file on physical location but I was only intended to check that whatever I am passing from “pre-build script arguments” box should be received in exe file.
So I read all those arguments and appended it as file name then it was display that unable to create file name “abc_10,20,30,40,50.txt” where “10,20,30,40,50” was the argument which I passed.
Thus it make sure that I can get all those parameter in exe file.
All the credit for this solution goes to stijn .
Upvotes: 1