views:

245

answers:

3

Hi, I've been searching this for a long while and i could find anything. I have 2 projects. One called ConsoleApp and other called ConsoleLib. ConsoleApp has a reference to ConsoleLib. How can i Tell visual studio to copy the assembly into a custom path instead of the app path? What i want to mean is that when i build the solution i want to get this folder structure

AppPath\ConsoleApp.exe
AppPath\Lib\
AppPath\Lib\ConsoleLib.dll

+2  A: 
  • In your ConsoleApp project refer the ConsolLib project which will receive the ConsolLib.dll in ConsolApp\Bin.

  • Now in the ConsoleApp project goto PostBuild commands there you can sepcify the operations you may wnat to execute after the build and there you can have it copied to ConsoleApp\Lib.

this. __curious_geek
+1  A: 

You need to use a postbuild command in the application project to create the lib directory and copy the library file into it.

If you decide to do this (which I wouldn't recommend unless you have lots of dlls and feel an overwhelming urge to organise them) you also need to add a probing path element to your app.config file that will tell it where to look for the libraries. See here.

Martin Harris
A: 

Use a postbuild command (I'm using subdir "release" in output)

mkdir "$(TargetDir)release\"
mkdir "$(TargetDir)release\bin\"

copy "$(TargetDir)*.*" "$(TargetDir)release\"
copy "$(TargetDir)*.dll" "$(TargetDir)release\bin\"
copy "$(TargetDir)*.pdb" "$(TargetDir)release\bin\"  

del "$(TargetDir)release\*.pdb"
del "$(TargetDir)release\*.dll"
del "$(TargetDir)release\*vshost*.*"

In app.config then :

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <probing privatePath="bin"/>
    </assemblyBinding>
</runtime>

Hope this helps

Joe Fuksa