views:

44

answers:

3

i am using some libraries and i added a reference to that library dll and i set the "Copy Local" to true.
but i want to change the location of the dll to be a subfolder in the exe folder and not with the exe.
how is this possible?
thanks

Update:
i used the following Post-build event [as Jon Skeet recommended]

move /y $(TargetDir)\System.Data.SqlServerCe.dll   $(TargetDir)\Lib\SqlSrvCe\System.Data.SqlServerCe.dll
+1  A: 

I don't know whether it's feasible within "normal" build rules, but you could add post-build steps which basically moved the files. It would be ugly, but it should work.

Jon Skeet
A: 

Do you need it as a reference? Or is the reference only to copy the dll to the desired location?

If you do not need the reference, try adding it to the project and setting it to always copy.

Add the dll to a folder in the project and set to Copy to Output Directory

Ed Chapel
i need it as a reference
Karim
+1  A: 

You'll need a .config file for your .exe so that the probing path is changed. A subdirectory is no problem, just use the <probing> element, its privatePath attribute is a relative folder name.

Beware however that you'll get little help from the IDE to put the DLL in that spot. You'll need a post build event that creates the folder if necessary and xcopy's the DLL there. Something like this:

if not exist $(TargetDir)mumble mkdir $(TargetDir)mumble
xcopy /d /y $(TargetDir)something.dll $(TargetDir)mumble
Hans Passant
this link contains the xml to put inside app.config for the probing path to work http://stackoverflow.com/questions/806467/how-can-i-set-privatebinpath-in-mef
Karim