Run an .exe from the build events

I want to run an executable from the "build events" (in the properties) of a c# project.

I tried to write the command as if I would write it in DOS - I tried with or without quotes like the following:

"C:\path\exename.exe -U param1"

or

C:\path\exename.exe -U param1

When I compile my project I get the following error:

Error 80 The command "C:\path\exename.exe -U param1" exited with code 9009. TryOnHost

Any ideas why I can't execute a program from there

Thanks.



Answer this question

Run an .exe from the build events

  • Ultrahead

    When you open the Visual Studio command prompt it will add that location to the path. But when using the pre/post build event this is not the case. You'll have to specify the path, you should be able to use Environment variables if you desire.

    Sayed Ibrahim Hashimi
    www.sedodream.com

  • PugJ

    BradFriedlander wrote:
    I am also trying to use gacutil in a pre- and post-build event. I get the same crytptic error code (9009). My commands are:

    gacutil.exe /u $(TargetName)

    and

    gacutil.exe /i $(TargetPath)

    Do we need a pathname to gacutil

    Is something else wrong

    gacutil is accessible from the VS command prompt.

    $(TargetName) will give errors because it isn't a filename.

    $(TargetPath) should work try gacutil.exe /i "$(TargetPath)" instead.



  • Ngoc Bui

    Uninstalling form the GAC is correct.

    But during installing it should be

    "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /i "$(TargetPath)"

    otherwise  the error "Excited with code 1 " occurs


  • Jarno Burger

    I face the same problem but I have the couple of .InstallLog files but the .InstallState file does not exist

    and I can't write the command in post- build command line to allow the service to install automatically without having to install it every time a new build is made


  • ODilbert

    Your output shows the application did run, it returned an errorcode (9009).

    The application is failing; you'll have to give us more information on the application if you need help finding out why the application is failing.



  • aryasheel

    I am trying to run "InstallUtil.exe" located by default in "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727" when you install the .net framework on a machine.

    I am coding a windows service and every time I compile, I have to manually copy the executable to the installation directory and then manually run InstallUtil.exe to uninstall the current version of the windows service and then run InstallUtil.exe to install the new version. I would like to automate this deployment process with the pre/post build events. I know how to deal with copying the files but every time I try to run the InstallUtil.exe I get that error code.

    Is there a place where I could find a definition of those error codes I googled a bit and I haven't found anything meaningful.

    Thanks for you help,

    Dom.


  • Craig Roberts Minnesota

    I am also trying to use gacutil in a pre- and post-build event. I get the same crytptic error code (9009). My commands are:

    gacutil.exe /u $(TargetName)

    and

    gacutil.exe /i $(TargetPath)

    Do we need a pathname to gacutil

    Is something else wrong

    gacutil is accessible from the VS command prompt.



  • sangeetha shanmugam

    Here's what finally worked:

    "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /u $(TargetName)

    and

    "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /i $(TargetPath)

    The primary problem was the lack of the full pathname to gacutil.exe.

    $(TargetName) work because the uninstall takes the assembly name, not the DLL filename.



  • Theo du Toit

    Yes there is a lot in those log files. Maybe that's where I will find the reason why the executable does not terminate properly ... I will try it again on Monday and let you know.

    Thx.


  • SmokeyPete

    There should be a couple of .InstallLog files and a .InstallState file in the directory of the assembly you're trying to install. If they're there; so they have any useful information in them

  • Run an .exe from the build events