Probing element in app.config + Post build event to copy multiple files
Probing is quite good to arrange assemblies in case if you have lots of private libraries referred to your executables and which are there under a probing path mentioned under the probing element in app.config file
When I started developing an executable , which demands to split its logic among several dlls and which are part of same solution and are deployed using simple xcopy method I found it quite convenent to use probing
path combined with postbuild script under project properties section of the main executable file .
Here in my example project, I have a dll project and an executable , which has been refered by the executable project in the same solution
The following post-script build script save me from copying the required files into Binaries\Libs folder strcuture under the current selected
build method(Release/Debug) . This is quite convenient in case to perform an xcopy of your binaries to the deployment folder. All the unwanted .vshost , pdb,manifest etc files are discarded and the probing directory
will get created under and the dll's are copied under the mentioned private probing path(s)
xcopy /Y $(ProjectDir)$(OutDir)*.dll $(ProjectDir)$(OutDir)Binaries\Libs\
xcopy /Y $(ProjectDir)$(OutDir)$(TargetFileName) $(ProjectDir)$(OutDir)Binaries\
xcopy /Y $(ProjectDir)$(OutDir)$(TargetFileName).config $(ProjectDir)$(OutDir)Binaries\
The app config section mentioned below make sure that the dll's are under the private path mentioned under it . It is possible to use multiple probing paths by separating them with (;) eg: bin;Libs\DataLib;ConfigLib
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Libs" />
</assemblyBinding>
</runtime>
Download the sample application source code here http://bit.ly/N4MneU
References
http://msdn.microsoft.com/en-us/library/823z9h8w.aspx (read about probing path)
Comments
Post a Comment