开发者

Best way to work with multiple projects / solutions in Visual Studio?

Currently I have 4 solutions that are independent projects, however there is quite a bit of duplicated code when it comes to a few areas of the applications.

At the moment it is simply a few forms and their associated code.

When I want to change or improve something, I have开发者_高级运维 to copy and paste to all relevant projects.

I looked at creating a new project within one of the solutions for the .dll/class library, but I felt that this was incorrect. (Please say if I am wrong).

As it is a component for all the applications, I decided to create a new solution for the .dll/class library and am looking at moving the shared code over to that - but, having never gone down this route before, what are my options from here?

Am I able to then include this solution within the others if I need to make a simple change and have it updated in all the projects or instead, should I always be working on the shared component in a separate instance of Visual Studio, outside of the applications using it?


That's exactly the right way to handle this situation.

You can include projects in multiple solutions by right-clicking the solution and selecting Add Existing Project...

Any changes you then make will appear in all solutions. The only problem this leads to is that it's possible to break one solution from another. This is where automated builds on commit to source control come into their own.


  1. Put shared codes in separate Solution/Project as Class Library,
  2. In post build event of shared projects copy dll's to a specific directory,
  3. Add shared dll's from this directory to other projects/solutions

By doing this each time you build your consumer projects, they will use latest dll's automatically.


Moving the common code into a separate shared assembly is an excellent option.

One thing to think about is to keep your common business logic or business object type code separate from UI related code like custom controls - if you need to then have two common assemblies. This is more work initially, but makes things way easier further down the track when you need to make UI changes or change the control suite you are using.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜