Visual Studio 2015 中的共享项目和类库有什么区别? [英] What is the difference between a Shared Project and a Class Library in Visual Studio 2015?

查看:27
本文介绍了Visual Studio 2015 中的共享项目和类库有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看 Visual Studio 2015 的新功能,并且出现了很多共享项目,但我不明白它与使用类库或可移植类库有何不同.谁能解释一下?

I was looking at the new features for Visual Studio 2015 and Shared Project came up a lot but I don't understand how it is different to using a Class Library or a Portable Class Library. Can anyone explain?

编辑:共享项目是 Visual Studio 2015 中的一项新功能,与可移植类库不同.我了解便携式类库是什么.我想了解的是共享项目与类库有何不同.请参阅下面的链接.

Shared Project is a new feature in Visual Studio 2015 and is different to a Portable Class Library. I understand what a Portable Class Library is. What I'm trying to understand is how a Shared Project differs to a Class Library. See link below.

http://www.c-sharpcorner.com/UploadFile/7ca517/shared-project-an-impressive-features-of-visual-studio-201/

推荐答案

共享项目和类库的区别在于后者是编译的,重用的单位是程序集.

The difference between a shared project and a class library is that the latter is compiled and the unit of reuse is the assembly.

而前者,重用单​​元是源代码,共享代码被合并到每个引用共享项目的程序集中.

Whereas with the former, the unit of reuse is the source code, and the shared code is incorporated into each assembly that references the shared project.

当您想要创建针对特定平台的单独程序集但仍有应共享的代码时,这会很有用.

This can be useful when you want to create separate assemblies that target specific platforms but still have code that should be shared.

另见此处:

共享项目引用显示在解决方案资源管理器的引用节点下,但共享项目中的代码和资产被视为链接到主项目的文件.

The shared project reference shows up under the References node in the Solution Explorer, but the code and assets in the shared project are treated as if they were files linked into the main project.

<小时>

在以前版本的 Visual Studio1 中,您可以通过添加 -> 现有项目然后选择链接在项目之间共享源代码.但这有点笨拙,必须单独选择每个单独的源文件.随着支持多个不同平台(iOS、Android 等)的转变,他们决定通过添加共享项目的概念来更轻松地在项目之间共享源代码.


In previous versions of Visual Studio1, you could share source code between projects by Add -> Existing Item and then choosing to Link. But this was kind of clunky and each separate source file had to be selected individually. With the move to supporting multiple disparate platforms (iOS, Android, etc), they decided to make it easier to share source between projects by adding the concept of Shared Projects.

1 这个问题和我的回答(到目前为止)表明共享项目是 Visual Studio 2015 中的一个新功能.事实上,它们在 Visual Studio 2013 更新 2

1 This question and my answer (up until now) suggest that Shared Projects was a new feature in Visual Studio 2015. In fact, they made their debut in Visual Studio 2013 Update 2

这篇关于Visual Studio 2015 中的共享项目和类库有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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