0

I'm wondering if its possible to set up and share an entire folder of source code between multiple projects in Visual Studio 2012 like how eclipse lets you use multiple source folders. I'm currently developing an entity framework model for a game I'm making with split server and client code, said framework currently sits in a class library referenced by both projects.

The reason I'd like to use a shared code folder instead is to add code to each entity component type by declaring the classes in the shared folder as partial and having another partial class in the client/server projects that adds sided functionality. I thought that achieving this would be more useful than extending each component on both sides, and it would also eliminate the need to have a DLL included with the product.

  • Usually this is a task better resolved by a Source Code Control (SVN, GIT, TFS and also Visual Source Safe are well suited to this) – Steve Jul 22 '13 at 14:27
  • I'm doing a similar thing for a similar reason, source code files are referenced from 2 projects - one web with EF, one mobile. There are some minor issues - attributes, references etc, but they can be dealt with easily. – Sten Petrov Jul 22 '13 at 14:27

2 Answers2

1

you can add a project to your solution (right click Solution -> Add -> Existing Project) and reference it (right click on your project -> Add Reference -> Solution -> Projects -> "Project you want to reference")

Visions
  • 919
  • 1
  • 7
  • 17
  • This is already in effect and is what I'm trying to avoid, the main problem is that the project would need compiled and would become its own assembly. This causes an issue because partial classes cannot be from different assemblies. – Richard Lang Jul 22 '13 at 14:32
  • Hm do you get runtime errors with that or compiletime? If it's runtime you can look into Ilmerge. Here's a little Tutorial: [Scott Hanselman's solution](http://www.hanselman.com/blog/MixingLanguagesInASingleAssemblyInVisualStudioSeamlesslyWithILMergeAndMSBuild.aspx) – Visions Jul 22 '13 at 14:43
  • The issue pertains to partial classes and trying to share source code (not assemblies) between two projects. Each project needs to be aware of the shared partial class and its own partial class. – Richard Lang Jul 22 '13 at 14:47
0

You can right click on a project and select - Add - Existing item.... Within the open file dialog select the desired file, click on the arrow next to the Add button and afterwards on Add As Link

OpenFileDialog with Add As Link option
(source: modbusdriver.com)

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Oliver
  • 43,366
  • 8
  • 94
  • 151