Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy non-code files with the compiled project when referenced by another project in C#

I have a project that acts as wrapper for a 3rd party .exe (it has static methods to create the command line and run the executable). I want to use it in at least a couple of projects in my solution. Ideally, the .exe should only be in that wrapper project (I don't want to have to add it to each project that uses it). Right now I'm trying to get this to work with a web project (.NET MVC) running on IIS 7 but when I use Assembly.GetExecutingAssembly().Location to see the directory that my wrapper is called from I'm in a folder like

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\"my project"\65a016fb\ac5f20a7\assembly\dl3\d8de0f10\06e277a2_55b2cd01

and my 3rd party .exe is nowhere to be found. Is it possible to copy files with a reference that do not compile?

Btw, I have set the "Copy to output directory" and "Build Action" properties of my .exe to "Copy always" and "Content"/"Resource"/"Embedded Resource" without success so far.

like image 443
DannyH Avatar asked Oct 25 '12 03:10

DannyH


1 Answers

Try to add an existing files in your projects which use your wrapper. When the dialog box appears, do this:

http://wiki.oxygenelanguage.com/en-w/images/0/0d/AddAsLinkAero.png

Either that or drag neccessary files to your projects from the wrapped with Alt holded.

That will add the files as links. Links are good choice for reusal whenever the original files has to be located in the only place.

Adding files as links in conjunction with setting to that links build action to Content and Copy always to the option of copying them to the output directory should work for your.

like image 117
AgentFire Avatar answered Sep 20 '22 16:09

AgentFire