Is there a way in .NET C# Console Application to deploy the executable to a different directory than the DLL’s it depends on?
In this case I would like to structure my deployment so that on the server where this will run I have the following directory structure.
c:\app\bin\sample.exe
c:\app\dll*.dll
It is fairly unwise, the CLR cannot find the DLL without help. Your customer won’t care much about the location of the DLL. In fact, I think most IT staff prefer binaries in the same directory.
If you put the DLL in a
c:\app\bin\dllsubdirectory then you can use anapp.exe.configfile with the<probing>element to tell the CLR to look in that directory. Deploying toc:\app\dllis much harder, it requires a very unpractical<codeBase>in a<dependentAssembly>. Which makes the app unmovable, prefer Pierre’s solution instead. Except that it needs work, you want to useAssembly.GetEntryAssembly().Locationto get the install path of the EXE so that you can generate a relative path off that.