none
Exe can't write file RRS feed

  • Question

  • Hi guys,

    As part of our build process I use the exec command to call an executable I have written myself, this works well and based on the error code it indicates if the executable has been successful or not as you'd expect.  The problem I have is sometimes the executable will error and I can't tell what the error is as I just have an error code which quite often is not something I expect (-50000000!!).  I have modified this executable to write to a log file progress and errors, if I run this exe myself it works fine, but through the Team Build the exec tasks run the exe and a log file is never generated.  I even make the exe write to the log "program started", but this doesn't happen if it is an automated build.
    I have run both manually and through the build with the same user account to prove it is not a rights problem.
    Can anyone explain why it runs different through the automated process?  Or how to configure this to work as I want.

    Running:
    Visual Studio 2008 SP1
    Team Foundation Server 2008 SP1

    Thanks for your help.
    John
    Tuesday, December 8, 2009 12:47 PM

Answers

  • Hi John,

    I tried it in MSBuild but cannot repro this problem, the application that Exec runs can create file succeed:

    <Exec Command="D:\\test.exe"/>

    The test.exe is a small program which generates a test.txt on D drive.

    I'm not a TFS expert, but as I know, the build automation runs in TFS will use the TFS account -- TFSBuildServices, please make sure your server account has the rights to create file.
    Second, could you please show me the code that calling Exec in the build file? sometimes the path of executable will cause problem(exited with code 9009), have you tried to move the executable to another path? such as: D:\\xxx.exe.

    I will test it on my colleague's TFS later because I don't have TFS installed.

    Sincerely,
    Wesley
    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by JCorker Monday, December 14, 2009 11:49 AM
    Wednesday, December 9, 2009 5:22 AM

All replies

  • Hi John,

    I tried it in MSBuild but cannot repro this problem, the application that Exec runs can create file succeed:

    <Exec Command="D:\\test.exe"/>

    The test.exe is a small program which generates a test.txt on D drive.

    I'm not a TFS expert, but as I know, the build automation runs in TFS will use the TFS account -- TFSBuildServices, please make sure your server account has the rights to create file.
    Second, could you please show me the code that calling Exec in the build file? sometimes the path of executable will cause problem(exited with code 9009), have you tried to move the executable to another path? such as: D:\\xxx.exe.

    I will test it on my colleague's TFS later because I don't have TFS installed.

    Sincerely,
    Wesley
    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by JCorker Monday, December 14, 2009 11:49 AM
    Wednesday, December 9, 2009 5:22 AM
  • I checked the TFS, it can also work for my test.exe.
    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, December 9, 2009 5:41 AM
  • In Team Build the build will execute under the account that the team build service is running under.
    If you want to execute a specifc command under a different account then you can use the Runas command line along with the Exec task.
    If this still doesn't work can you paste the actual error here? Also is there any info available in the event viewer?


    My Book: Inside the Microsoft Build Engine: Using MSBuild and Team Foundation Build
    My Blog: sedodream.com
    Visual C# MVP
    Wednesday, December 9, 2009 6:53 AM
    Moderator
  • Hello,

    How are you? Is your problem resolved? May I know whether the above suggestions helped you?

    Thanks,
    Wesley


    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, December 14, 2009 3:00 AM
  • Hi,

    Sorry for the delay in getting back to you.  Things got more complicated last week as we installed TFS 2010 and I then realised I needed to create WorkFlow activities instead of my custom EXEs that I had in MSBuild. 
    So I now have converted this exe into a Workflow code activity and have added to my build template which all seems very cool.  In the conversion process I have removed the debug write to file code, and hope to find a way to output errors to the build progress screen in Visual Studio.

    Thank you for your help on this though, I don't think it was a user account rights issue.  Possibly I made an error in using a relative path to create the file which worked fine for me but not for the build process, but as I say we have now moved on to cooler things.

    Cheers,
    John
    Monday, December 14, 2009 11:49 AM