How to save DLLs in a different folder when compil

2019-01-11 01:12发布

Let's suppose I have a Window Forms / Console Application C# project with some external references and references to other class library projects in the same solution too.

When I build the Window Form project, I want the referenced libraries be stored in a different location (eg: bin\Release\Libraries), and not in the same folder as the .exe.

Is it possible to do?

5条回答
相关推荐>>
2楼-- · 2019-01-11 01:29

Correct answers were given earlier. I'll just mention that there is a nuget package for this called PrettyBin.

Install it on your startup project. DLLs and XMLs will go to a lib folder and you'll have a working example of how it's done, if you won't to customize.

查看更多
神经病院院长
3楼-- · 2019-01-11 01:31

Yes it is possible, you'd do it in your msbuild script. While I can't give you an exact answer, look here at this question on SO Copy all files and folders using msbuild

查看更多
何必那么认真
4楼-- · 2019-01-11 01:33

You'll find best practices for organizing project references here: http://codebetter.com/patricksmacchia/2009/01/11/lessons-learned-from-the-nunit-code-base/

Look under chapter "The VisualStudio Project Reference + Copy Local true option is evil!"

查看更多
beautiful°
5楼-- · 2019-01-11 01:39

There are 2 parts of your question:

How to configure solutions to build assemblies/EXE into folders of your choice - this is configured through properties of the project in VS (project properties -> build -> output path). Also value of check "copy local" property on each reference.

How to load assemblies files from non-default locations (i.e. from your ...\Libraries folder) - you need to make changes to your app.config file to add this non-default paths to assembly search location ( http://support.microsoft.com/kb/837908 ).

查看更多
疯言疯语
6楼-- · 2019-01-11 01:48

Set Reference path in project peoperties.

You can also specify where your compiled exe goes by specifying Output path in project peoperties.

查看更多
登录 后发表回答