Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
164 views
in Technique[技术] by (71.8m points)

c# - Build DLL to a separate folder

First

There are several questions similar to this, but none have answers that solved my problem nor can I post in them. The closest one is in this question.

I found the answer here. And I am posting here so I can found it later.

The Question: How to build my project and have all my Referenced Library inside a lib sub-folder?

A want this output directory:

Lots of DLLs in the main folder

To be stay like this:

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I found the answer here and transcribed here for the case of the link die.

In your App.config file, insert this:

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

Then go to Project -> Properties --- right click in your Project, then in the ContextMenu select Properties.

Now go to Build Events and add the following code inside the Post-build event command line text box (as you can see in the bellow image).

; Move all assemblies and related files to lib folder
ROBOCOPY "$(TargetDir) " "$(TargetDir)lib " /XF *.exe *.config *.manifest /XD lib logs data /E /IS /MOVE
if %errorlevel% leq 4 exit 0 else exit %errorlevel%

Post-build event command line

After

Build your project and say good bye to your OCD!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...