A blog covering reverse engineering, security, and portable software development


Stoppt die Vorratsdatenspeicherung - www.vorratsdatenspeicherung.de

Importing VS 2005 project files into VS 2008

When importing Visual Studio 2005 project files (or whole solutions) into the new Visual Studio 2008 code named ‘Orcas’, you might find it interesting to know that under some circumstances important project settings are not set to their original value.

I found this problem when importing the VS 2005 solution of TrueCrypt into VS 2008. Importing the solution does not show any error and compiling the imported project works fine.

However, when testing the performance with the TrueCrypt built-in benchmark, I was a bit shocked:

The speed of the VS 2008 compiled code was up to 76% slower than the same code compiled with VS 2005. My first tought was that this might be Microsoft’s solution for converting C/C++ developers to use the .NET platform ;-). But my second thought was that this could have only been caused by bad compiler optimization settings.

Thanks god, my second guess was right:

When looking at the C/C++ project configuration settings under Studio 2008, I realized that the code optimization was set to ‘user defined’ (for the ‘Release’ configuration). The same setting is set to “Maximize speed /O2″ under Studio 2005.

When inspecing the .vcproj files of both Studio versions, you will see that there are no big differences.

These are the values for the ‘Optimization’ attribute of a .vcproj file:

  • 0 – Disable optimization (/Od)
  • 1 – Minimize size (/O1)
  • 2 – Maximize speed (/O2)
  • 3 – Full optimization (/Ox)
  • 4 – User defined

These settings are the same for the 2005 and 2008 version. However, the behavior is different if this attribute is not specified inside the project file (which is the case for all TrueCrypt project files and the ‘Release’ configuration).

Visual Studio 2005 will set the default value for a missing setting to ‘Maximize speed (/O2)’, where Visual Studio 2008 will set the default value to ‘User defined’.

My personal opinion is that the default behavior of VS 2008 is correct. Generally fixing such wrong behaviors is good. However, in a perfect world the ‘old project file import handler’ should have inserted an XML element with Studio 2005’s default setting (Maximize speed). This would probably have been the best user experience.

1 Comment so far

  1. dave August 20th, 2008 12:10 am

    Yeah, we tripped over this as well and wasted a day finding it. For us it was worse: the project properties showed that all projects in the solutions were set to Optimize Speed (/O2) but the /O2 was omitted from the command line!

Leave a reply