Visual Studio中:添加项目/添加为链接,而不是仅仅添加 [英] Visual Studio: Add Item / Add as link rather than just Add

查看:185
本文介绍了Visual Studio中:添加项目/添加为链接,而不是仅仅添加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Visual Studio,Delphi的到来。

I'm new to visual studio, coming from Delphi.

我有充分的文件的.cs(根\Common)。结果
我也有充分的应用程序的目录树的目录树(根\Applications)结果
最后,我有一个树上开满组件(根\Assemblies)

I have a directory tree full of .cs files (root is \Common).
I also have a directory tree full of Applications (root is \Applications)
Finally, I've got a tree full of Assemblies (root is \Assemblies)

我想保持在Assmblies树通用树和所有的环境巫毒(解决方案,项目设置,元数据,调试数据,仓等)我的.cs文件。因此,一个简单的例子,我有叫PdMagic.Common.Math.dll组装。解决方案和项目位于\Assemblies\Common\Math。其所有源(的.cs)文件是\Common\Math。 (matrix.cs,trig.cs,mathtypes.cs,mathfuncs.cs,stats.cs等)

I'd like to keep my .cs files in the Common tree and all the environment voodoo (solutions, projects, settings, metadata, debug data, bin, etc.) in the Assmblies tree. So, for a simple example, I've got an assembly called PdMagic.Common.Math.dll. The Solution and project is located in \Assemblies\Common\Math. All of its source (.cs) files are in \Common\Math. (matrix.cs, trig.cs, mathtypes.cs, mathfuncs.cs, stats.cs, etc.)

当我使用添加现有项添加matrix.cs我的项目,一个的复制的它被添加到\Assemblies\Common\Math文件夹。我只是想引用它。我不想多份周围铺设。我试着添加现有项,并使用下拉菜单添加链接,而不仅仅是添加,这似乎做我想做的。

When I use Add Existing Item to add matrix.cs to my project, a copy of it is added to the \Assemblies\Common\Math folder. I just want to reference it. I don't want multiple copies laying around. I've tried Add Existing Item, and used the drop down to "Add link" rather than just "Add", and that seems to do what I want.

问题:什么是最佳实践为这样的事情?多数人只是把这些文件的.cs都在同一文件夹中的项目吗?为什么不是添加链接默认?

Question: What is the "best practice" for this sort of thing? Do most people just put those .cs files all in the same folder as the project? Why isn't "Add link" the default?

谢谢!

推荐答案

在最佳实践在这种情况下,是不争的工具。它可以让你做你想做的,但你会得到更多的工作,并能够专注于代码,如果你只是让IDE组织项目适合你。

The "best practice" in this case, is to not fight the tool. It allows you to do what you want, but you'll get more work done and be able to focus on code if you just let the IDE organize your project for you.

我想创建一个名为PdMagic.Common一个空的解决方案项目

I would create an empty solution project called PdMagic.Common

这会给你喜欢

PdMagic.Common\
PdMagic.Common\PdMagic.Common.sln

然后我一般添加src和libs文件夹(通过文件系统,而不是VS)

then I generally add a src and libs folder (via the file system, not VS)

libs文件夹里面,我会放在我所有的第三方的依赖,以及src文件夹将举行我所有的项目

inside the libs folder, i would place all my third party dependencies, and the src folder would hold all of my projects

PdMagic.Common\
PdMagic.Common\PdMagic.Common.sln
PdMagic.Common\libs
PdMagic.Common\libs\nunit
PdMagic.Common\src

接下来,在Visual Studio中,我想右击我刚刚创建的解决方案,然后单击添加 - >新项目,我将指定我想它在\src文件夹中创建并调用它PdMagic.Common.Math

Next, in Visual Studio, I would right click on the Solution I just created, and click "Add -> New Project", I would specify that I wanted it created in the \src folder and call it PdMagic.Common.Math

现在我的文件夹结构看起来像这样

Now my folder structure would look like this

PdMagic.Common\
PdMagic.Common\PdMagic.Common.sln
PdMagic.Common\libs
PdMagic.Common\libs\nunit
PdMagic.Common\src
PdMagic.Common\src\PdMagic.Common.Math
PdMagic.Common\src\PdMagic.Common.Math\PdMagic.Common.Math.csproj
PdMagic.Common\src\PdMagic.Common.Math\Class1.cs

然后,当你添加类的PdMagic.Common.Math项目,他们会与项目文件中的文件夹中。这是IDE如何有我们应该努力的意见,我想大多数开发商去用它,因为试图让文件系统上的任何其他布局将需要与IDE太多的战斗。我知道这是很难来自不同的约定,你本能地想在新的环境相同的约定。但是,如果你坚持公约,(对还是错在你看来),你会做更多的事,因为你不会试图迫使IDE做的事情,你认为他们应该做的方式。

Then, as you add classes to your PdMagic.Common.Math project, they will go in the folder with the project file. This is how the IDE has the opinion we should work, and I think most developers go with it because trying to get any other layout on the file system would require too much fighting with the IDE. I know it can be hard to come from a different convention, and you instinctively want the same conventions in the new environment. However, if you stick with the conventions, (right or wrong in your opinion) you'll get more done because you won't be trying to force the IDE to do things the way you think they should be done.

这篇关于Visual Studio中:添加项目/添加为链接,而不是仅仅添加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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