AUROS
asked on
C# class library using an external executable
Hi all,
I have a C# class library that uses an external executable (launching it through Process.Start).
I want the executable to be automatically copied to the bin folder of any application using this library, in the same manner that any DLL used by my library is copied to the using applications' bin folder, (without the need of adding a post build script to each of these applications).
The executable is currently part of the class library project, and is defined as "Resource" and "Copy if Newer".
I'm using VS2008.
Any idea if and how this can be accomplished.
Thanks in advance.
I have a C# class library that uses an external executable (launching it through Process.Start).
I want the executable to be automatically copied to the bin folder of any application using this library, in the same manner that any DLL used by my library is copied to the using applications' bin folder, (without the need of adding a post build script to each of these applications).
The executable is currently part of the class library project, and is defined as "Resource" and "Copy if Newer".
I'm using VS2008.
Any idea if and how this can be accomplished.
Thanks in advance.
ASKER
That's not exactly what I meant...
I'll explain:
In my class library I have the following code:
Process.Start("SomeProgram .exe");
Now in order for this to work, I need each program that adds a reference to my DLL to add the following to the post build event of their application:
xcopy "$(SolutionDir)\..\Common\ MyClassLib rary\bin\d ebug\SomeP rogram.exe " "$(TargetDir)" /d /s /i /r /y
What I'm looking for is some workaround so that I won't have to add the post-build event for each application.
Thanks.
I'll explain:
In my class library I have the following code:
Process.Start("SomeProgram
Now in order for this to work, I need each program that adds a reference to my DLL to add the following to the post build event of their application:
xcopy "$(SolutionDir)\..\Common\
What I'm looking for is some workaround so that I won't have to add the post-build event for each application.
Thanks.
As I understand your problem, you want to include an external executable as part of the build project of an assembly and you want this executable to end up in the executable directory of any executable solution that includes your auxilliary assembly library.
Here's why your previous solution is failing: At the time that the library assembly builds it determines that it needs to copy the external exe to the output directory so it does. However, this output build directory belongs to the library assembly, not the executable solution that is including the library assembly. When the executable is built it copies the library assembly but knows nothing about the external executable.
There are two build time solutions:
1) Change the output directory of the library assembly to be the same as the one used by solution's executable.
2) Add the external executable to the solution's executable.
Here's why your previous solution is failing: At the time that the library assembly builds it determines that it needs to copy the external exe to the output directory so it does. However, this output build directory belongs to the library assembly, not the executable solution that is including the library assembly. When the executable is built it copies the library assembly but knows nothing about the external executable.
There are two build time solutions:
1) Change the output directory of the library assembly to be the same as the one used by solution's executable.
2) Add the external executable to the solution's executable.
You can reference an .exe the same way that you reference a .dll, through the Browse tab of the reference window.
Simply do that an then make sure that the Copy Local property of the reference is set to True.
Simply do that an then make sure that the Copy Local property of the reference is set to True.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
no solution found
u can change the files path
or use the current directory of the class library to detect where is the
executable file exist and the bin folder
mohamed Naguib
Open in new window