views:

553

answers:

2

I've read a few posts around here about the GAC and why you should never deploy applications by installing shared assemblies into the GAC. This i can see sense in as it should make updating applications on client machines easier.

However, there are two areas where i could see the GAC being useful is for during development and on a build server.

For instance, if you use the Microsoft Application Blocks you could well install them into the GAC and reference them there. That makes sense as it is easier to do this than have and absolute reference to a path with might be different on each developers machine. It is also better than having a shared network drive with all your shared components - been there done that.

You would then presumably do the same for your build server. However the only problem i see with this is that you have an app that uses version 2.0 of the application blocks. Later on you upgrade this to use version 3.1. At some point you might need to re-create your earlier version of that application to test a bug a customer has found but when you recreate the build it will pick up version 3.1 of the application block rather than 2.0 which it was originally built against. Is this true, or will the old project file still reference the older version of the dll so long as it is in the GAC?

What are your thoughts/opinions on this particular point?

I would like to be able to distribute all version of shared components (we either download or build) to all developers as MSI's which install into the GAC and are 'XCOPY' deployed as part of an application installer to customer machines. Is this the best way to do this.

A: 

The old application will pick the older version of the assembly from GAC provided that you don't rebuild the old application with the newer assembly. Every assembly keeps this information in it's own manifest that which assemblies does it refer to. If you open up an assembly using ILDasm tool, you can inspect the Assembly's manifest in detail which keeps the information of all the referred assemblies.

Aamir
+2  A: 

What are your thoughts/opinions on this particular point?

I always keep primary binaries in the Resource/Library folder of the .NET software project. Obviously this folder is versioned. Storage is cheap these days anyway, so it does not make a big difference.

This serves a few purposes:

  • Projects are atomic and they do not depend on having a specific version of some library in GAC. So it is easy to reproduce some previous revision by simply checking it out. And everything will work.
  • It just requires a clean development machine (with all the .NET service packs and primary SDKs installed, of course), in order to start check out a project, run full integration build and start working.

When there are more than 10 different projects to manage, this starts making some difference.

Rinat Abdullin
I can see your point about projects being atomic and making it easy to reproduce previous versions. But it does put a burden on the developer to make sure they get the correct version of an assembly. I think this approach also has a problem when you work with source control as checking in and potentially merging assemblies could leave to developers working on the sam project but with different versions of a shared assembly overwriting the correct version. At least with a project reference you can see the assembly version number during a merge.
I guess that depends on the development practices. In Lokad we have people from different countries working on same projects (closed or open-sourced). There hadn't been a single issue, yet.
Rinat Abdullin