After building copy Assembly at some specific folder
You have created one Class Library project e.g “BusinessLogic” and other projects are also using it and they are referencing it from C:\MyLibraries folder. Where you put this “Business Logic” Class library. But what happens that you do some changes in your library and forgot to copy it at c:\MyLibraries location. And people starting shout on you…If you are using Visual studio than this thing you can automate using a feature called “Post Build Event”.
Sounds good idea na….so lets see how can you achieve this step by step:
- Right click on your class library and click on properties
- It will open up window in left side with list of tabs
- Click on “Build Events” Tab.
- Here you can see two things:
- PreBuild event: comes in action before build.
- Postbuild event: comes in action after build.
- you can use this DOS Command for achieving the task
COPY Source destination
Click on edit post build event button which will open a window. Here you can see
List of Macros like
TargetDir = your current Class library Bin/debug directory
TargetFileName = your Class library .dll name
And so on which you can explore on your self.
So for copying my .dll to C:\MyLibraries folder I have written like this:
Copy $(TargetDir)\$(TargetFileName) $(TargetDir)\..\..\..\..\ MyLibraries
..\..\..\ = this syntax is for coming up level from child directories. So based on your depth level you can use it wisely.