Visual Studio:如何管理项目之间共享的代码 [英] Visual Studio : How to manage code shared between projects
问题描述
这可能以前发布过,但我不确定要查找什么搜索词!
This has probably been posted before, but I'm not sure what search terms to look for!
快速解释.
我有几个项目共享的代码.此代码本身仍在进行中.问题是,每当我需要更新此代码时,我都不想更新 3 次,这将成为一场噩梦.
I have code that is shared between a few projects. This code is still work-in-progress itself. The issue is that whenever I need to update this code for whatever, I don't want to have to do it 3 times, this will become a nightmare.
有没有办法将它添加到项目中,而无需将其复制到项目文件夹中?即我希望将共享类作为
Is there a way to add it to a project, without copying it into the project folder? i.e. I want the shared class to be linked into my 3 projects as
C:\code repository\sharedclass.cs 不是 \eachproject\bin\sharedclass.cs
C:\code repository\sharedclass.cs NOT \eachproject\bin\sharedclass.cs
我是否必须将其创建为自己的库项目?如果编译器可以将其编译为外部"代码,那就更好了.
Do I have to create it as it's own library project? It would be much better if the compiler could compile it as 'external' code.
干杯.
推荐答案
最好将公共部分提取到一个单独的项目库中,并将该项目的引用添加到所有解决方案/依赖项目中.
It is better to extract common part into a separate project library and add reference of this project to all the solutions/dependent projects.
否则您可以添加代码/文件/项目作为链接.
这篇关于Visual Studio:如何管理项目之间共享的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!