相关性和参考 - 究竟应该怎么引用? [英] Dependencies and references - What exactly should I reference?

查看:94
本文介绍了相关性和参考 - 究竟应该怎么引用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我的建设项目时,包括什么。我有一个图书馆中,我需要引用我的项目建设,但该库有10个依赖本身。我应该引用那些依赖以及或者我应该使用后生成事件将它们复制到输出目录?

I am wondering what to include when building my project. I have a library I need to reference for my project to build but that library has 10 dependencies itself. Should I reference those dependencies as well or should I copy them to the output directory using a post build event?

什么是最好的做法是什么?

What is the best practice?

我觉得很混乱,包括所有这些依赖作为该项目编译好没有他们 - 他们那时叫运行时依赖?我引用变得混乱与依赖无关紧要到我的项目,即使他们是在一些图书馆,我,包括使用。

I find it confusing to include all those dependencies as the project compiles fine without them - are they then called runtime dependencies? My references become cluttered with dependencies irrelevent to my project even though they are used in some library I am including.

我在使用Visual Studio。

I am using Visual Studio.

有人可以给我一些见解如何做到这一点的权利。

Can someone please give me some insight into how to do this right.

感谢。

推荐答案

您只需要补充的是直接使用你的项目引用。

You only need to add references that are directly used by your project.

有关专用程序集(那些没有在GAC),Visual Studio将在默认情况下,复制引用的程序集(和它们的依赖)到项目的输出目录。

For private assemblies (those not in the GAC) Visual Studio will, by default, copy referenced assemblies (and their dependencies) to your project's output directory.

有关在GAC Visual Studio的组件默认情况下不被引用程序集复制到项目的输出目录。

For assemblies in the GAC Visual Studio doesn't copy the referenced assembly to your project's output directory by default.

在这两种情况下,你可以通过更改复制本地引用属性变更的行为。

In both cases you can change the behavior by changing the "Copy Local" reference property.

恕我直言,这是构建环境的一个漂亮的功能。在非托管的世界是由你来保持跟踪你的依赖的依赖(通常是通过pre或交建事件)。

IMHO, it's a nifty feature of the build environment. In the unmanaged world it's up to you to keep track of your dependencies' dependencies (usually through pre or post build events).

这篇关于相关性和参考 - 究竟应该怎么引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆