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 system was developed using C#/.Net 3.5.
Is there any way to achieve this?
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 system was developed using C#/.Net 3.5.
Is there any way to achieve this?
Check this. The idea is that you get the list of assembly attributes using Assembly.GetCustomAttributes() and search for DebuggableAttribute and then find if such attribute has IsJITTrackingEnabled property set.
public bool IsAssemblyDebugBuild(Assembly assembly)
{
return assembly.GetCustomAttributes(false).OfType<DebuggableAttribute>().Any(da => da.IsJITTrackingEnabled);
}
I loved that David suggestion, but you could also go this way (AssemblyInfo.cs):
#if DEBUG
[assembly: AssemblyDescription("Your application assembly (DEBUG version)")]
#else if RELEASE
[assembly: AssemblyDescription("Your application assembly (RELEASE version)")]
#endif
This is more human friendly, as anyone can right-click that assembly, to select Properties and go to Details tab.
Don't deploy to production via Visual Studio. Look into Continuous Integration and scripted builds (such as with NAnt, or perhaps something more legible like FAKE).
The F5 Key Is Not a Build Process
To detractors who believe that this does not answer the question, the OP wrote:
...I need to guarantee that all the assemblies that are going to be deployed were built using Release configuration.
To guarantee that, use a build server such as TeamCity and possibly a release management tool like Octopus Deploy. Lock down your production systems so that developers must go through the official build process.