10

Is it good practice to set AssemblyConfigurationAttribute in .Net assembly files?

John Simons
  • 4,288
  • 23
  • 41
  • 5
    It doesn't matter what you set it to, "Retail" or "Release" would be logical choices. Microsoft doesn't use it in their own assemblies. – Hans Passant Nov 20 '12 at 23:27
  • 2
    I agree, in earlier versions of .NET/MSDN documentation they told you it is optional but should/could be set to debug or retail, but in the current documentation there is almost nothing about it. Sounds depreciated to me. – Tony Wall Jun 22 '13 at 14:24

1 Answers1

4

I have not found this to be particularly useful (since none but the most low-level tools display this information) and I have never seen it used in production code I have worked on.

Regardless, if you want it, just add the following lines to your AssemblyInfo.cs file:

#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly: AssemblyConfiguration("Release")]
#endif
Jeff Prince
  • 658
  • 6
  • 13
  • 6
    I'd actually replace `#else` with `#elif RELEASE`. It doesn't seem right that anything non-`DEBUG` is automatically considered `RELEASE`. And if, for some reason, both preprocessor symbols are undefined, then it seems only proper not to emit the custom attribute at all. – stakx - no longer contributing Aug 05 '16 at 10:37