Visual Studio: Upgrading solutions and projects from the command line

I wanted to build some projects created with Visual Studio 2005 on a machine with Visual Studio 2010. While compiling from the command line, I got the following error message:

Solution file 'xxx.sln' is from a previous version of this application and must be converted in order to build in this version of the application. To convert the solution, open the solution in this version of the application.NMAKE : fatal error U1077: 'if' : return code '0x1'

Of course Visual Studio will convert the solution/project when you open it. But I had about 60 projects and didn’t really feel like opening them all. So I looked for a command line solution. There are basically two ways to do it:

  1. Using devenv /upgrade
  2. Using vcupgrade

Here the syntax for devenv /upgrade:

devenv /upgrade xxx.sln

or if you want to convert a project:

devenv /upgrade xxx.vcproj

The problem with devenv /upgrade is that if it finds a .vcxproj file, it will display a popup dialog asking whether it should be overwritten. And there is unfortunately no command line argument to say that you always want to overwrite. So when calling it 60 times in a row, you could end up having to answer this question 60 times in a row.

There is a checkbox in the dialog in order not to be asked again in this session but since a session is a call of devenv /upgrade, it only makes sure that you do not get a message per project in the solution but it doesn’t prevent getting a message per solution.

The solution is to use vcupgrade which does provide such an option:

vcupgrade /overwrite xxx.vcproj

The problem with vcupgrade is that it only works with project files and not solutions.

So if you just want to upgrade projects, you can use vcupgrade. But if you want to upgrade solutions, you are stuck with devenv /upgrade.
Of course you can just delete the .vcxproj if there are any in order not to get the dialog.

Leave a Reply

Your email address will not be published. Required fields are marked *