I\'m starting deployment of my web application and I need to guarantee that all the assemblies that are going to be deployed were built using Release configuration. Our syst
If it is your assembly I believe using the AssemblyConfiguration attribute is the best approach. It is documented as "Specifies the build configuration, such as retail or debug, for an assembly."
Depending on your build configurations you might have code like this:
#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly: AssemblyConfiguration("Release")]
#endif
Then check the assembly attribute:
public static bool IsAssemblyConfiguration(Assembly assembly, string configuration)
{
var attributes = assembly.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false);
if (attributes.Length == 1)
{
var assemblyConfiguration = attributes[0] as AssemblyConfigurationAttribute;
if (assemblyConfiguration != null)
{
return assemblyConfiguration.Configuration.Equals(configuration, StringComparison.InvariantCultureIgnoreCase);
}
}
return true;
}
(I know R. Schreurs comment at Rubens Farias says the same, but I've find this information somewhere else before seeing the comment so I believe this requires a more important entry like a full response instead of a comment)