views:

19

answers:

1

We have a Visual Studio 2010 solution, with C#/C++/VB.Net as well as other projects. It is not MsBuild-based.

My co-workers and I mostly work with Debug build, and Release is rarely used, but is used indeed (say that there is a Release-only bug; those do pop-up from time to time.)

The nightly builds follow their own separate process, and create something that is somewhat equivalent to a Release build that a developer would use, but not the same. Anyhow ... without going into too much details,

I would like to add a unit test which checks the symmetry of the Debug and Release configuration for a given solution platform (in our case it is Win32).

I would prefer a C# solution or a Python solution (because that is what we use for testing currently), but Perl and PowerShell can also be ported without too much effort.

By a "solution" I do not mean that I need a full-blown unit test which compiles and works as desired (although complete answers tend to attract more votes over time); a relevant chunk of code that gets me started would be good enough.

My biggest difficulty is in parsing the Visual Studio solution file, which is not MsBuild-based (so I was told, I guess it means that it is not pure Xml, but a funny MSFT ASCII format).

Let me know if you have questions. Once again, I would like to find all differences between Debug+Win32 and Release+Win32. i am not sure if Win32 thing is standard, or internally-brewed.

Thanks!

A: 

In order to determine whether or not the assembly was compiled in debug mode, get the Debuggable attribute from the assembly. Assuming that you have an Assembly instance, this is how you would do it:

// The assembly is in a variable named assembly.
object[] attributes = assembly.GetCustomAttributes(typeof(DebuggableAttr ibute), true);

// If the array is null, or has length of zero, then it is not debuggable.
if (!(attributes == null || attributes.length == 0))
{
    // It is debuggable, figure out the level.
    DebuggableAttribute debug = (DebuggableAttribute) attributes[0];

    // At this point, you can access the DebuggingFlags property to
    // determine the level of debugging.
}
Ben.Vineyard
Thanks, but I am interested in working on .sln file, not the result of the compiled dll(s). I hope I did not misunderstand your answer.
Hamish Grubijan
It was I that misunderstood your question. I guess in my head I assumed that interrogating the code was the only way to detect.
Ben.Vineyard