How to compile and deploy an assembly to a custom path using visual studio?

I searched for this for a long time and I could find something. I have 2 projects. One is called ConsoleApp and the other is called ConsoleLib. ConsoleApp has a link to ConsoleLib. How can I tell visual studio to copy the assembly to the custom path instead of the app path? I want to say that when I create a solution I want to get this folder structure

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

+1


a source to share


3 answers


  • In the ConsoleApp project, refer to the ConsolLib project, which will receive the ConsolLib.dll in ConsolApp \ Bin.

  • Now, in the ConsoleApp goto project of PostBuild command, you can separate the operations that you can do after build, and there you can copy it to ConsoleApp \ Lib.



+2


a source


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



If you choose to do this (which I would not recommend if you have a lot of DLLs and feel overwhelmed to organize them), you also need to add a tracking element to your app.config file that will tell you where to look for the libraries. See here .

+1


a source


Use the postbuild command (I use subdir "release" in the 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 it helps

0


a source







All Articles