Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: Elegant way of copying native dependencies next to my exe

Tags:

c#

Currently I am using a post-build event command line similar to this one:

xcopy /Y /R d:\svn\some\directory\somedll.dll  $(TargetDir)

The problem is this: when others check the code out to another directory they will have to fix the path in this command. Is there a less hackish way of doing this?

like image 392
George Avatar asked Dec 05 '25 17:12

George


2 Answers

Assuming d:\svn\some\directory is at a fixed location relative to your .sln file, you can use a relative path something like this:

xcopy /Y /R $(SolutionDir)..\directory\somedll.dll $(TargetDir)

(Note that the value of $(SolutionDir) includes a trailing backslash.)

like image 60
RichieHindle Avatar answered Dec 08 '25 06:12

RichieHindle


If d:\svn\some\directory is within your solution folder then you can add somedll.dll to your Visual Studio solution and set "Copy to Output Directory" to "Copy always" in the file properties.

like image 40
dtb Avatar answered Dec 08 '25 07:12

dtb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!