Wednesday, November 30, 2005

Find whether a .NET assembly is Release or Debug build

Bangalore
1 Nov 2005

Applies to : VS.NET 2003

Many a times, I would be at the mercy of the developers to do a release for me. This lead to the question; how do I know if they have done a release or debug build.

Since there was no straight forward answer to find this out. I decided to use the AssemblyInfo.cs file to help me out.

But which attribute should I use....

After probing the properties of an assembly (dll) file. I came to a conclusion that the best place to put it is the AssemblyProduct attribute.

So using a combination of pre processor directives I was able to accomplish my goal.

The code snippet is as follows.


#if DEBUG
[assembly: AssemblyProduct("Product Name [Debug Build]")]
#else
[assembly: AssemblyProduct("Product Name [Release Build]")]
#endif

Musing
It would be really great if a generic assembly attribute can be created which takes in any attribute name. Why?... mainly because all the attributes are name value pairs, so if I enter a custom attribute it should also be displayed under the files Properties - Version Tab.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home