How to reference assembly once for all projects in solution

I have several solutions, each of which contains several projects, and all of them should refer to one assembly, say, lib.dll.

It contains common classes and functionality that must be addressed between all solutions; and I can’t bring all the projects into one solution, as my manager wants to be able to use different versions of lib.dll between different solutions. I am also stuck on VSS and 2005 at the moment (sympathy for voices?).

Currently, I have to reuse links in all projects in a solution manually; what I really want is to be able to do everything in one place, but obviously the GAC for that.

Do I have any way, say, a dummy project, which can be referenced by all other projects in a specific solution, which will provide lib.dll when referenced?

Am I barking the wrong tree here?

+4
source share
4 answers

First, select a known location where the DLL can be deployed in your source tree. Add a custom build step to the shared library to copy the build result to this known directory (using relative paths). Then, adding links to the shared library, link to it in this famous place (make sure the link hintpath uses relative paths in the vcproj file).

I use relative paths, so the placement is in the source tree, which goes to the original control ... if someone takes the same tree from the original control, it works as expected. Alternatively, you might have an environment variable on the machine pointing to a shared path. This alternative means that several copies of the source tree on the same computer can fool each other, but then the solutions do not have to be located in a fixed way relative to each other. This share may also be on the network path, but then, if other developers build their changes, they will be overwritten by each other.

0
source

Project files are just XML documents, so parsing in a script (here is a good choice for IronPython), checking for a link, and also inserting or updating as needed should be a relatively trivial issue to achieve.

+1
source

Even if you created a dummy project referencing lib.dll (for example, project.dll), you still have to add a link to that dll in all your other projects in the solution, so that you will be in the same situation, just with a different assembly.

One more note: if in the future different versions for lib.dll are released, and different projects refer to different versions for this DLL, then you may not even want to do what you are describing, because you will only reference one version of the dll that would be wrong anyway.

What I usually do to consolidate frameworks or libraries, stores them in a shared folder and links to them (for example, in the Links folder or something like that). I also have my team mimicking the same folder structure. We have that checked in our repository as well as all links are good. If we change, we need to change the dll, then we just check the file, overwrite it, put it back and reinstall the solution.

0
source

The PAC should still work. You can have multiple versions of the same DLL in the GAC.

0
source

All Articles