views:

991

answers:

1

I'm trying to use visual studio 2010. But it seems that the .sln file that is created through it isn't supported by previous versions. Is it possible to save the projects in a way that it could be readable by previous versions of visual studio (2008).

+3  A: 

The accepted answer is incorrect when it comes to projects. It's correct for solution files, but they're not actually as important as the project files (as they don't change as often, in my experience, and there are fewer of them).

For example, you might want to look at Noda Time. We have two solution files (NodaTime VS2008.sln and NodaTime VS2010.sln) which load the same project files. This provides a pretty practical solution to having developers working with different versions of Visual Studio.

Manually change the first part of the project file to look like this:

<Project ToolsVersion="4.0" DefaultTargets="Build" 
         xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;

(Basically just change ToolsVersion to 4.0.)

You can also just let VS2010 convert the projects automatically and compare them afterwards if you want - see whether it's done anything else that you don't want.

At that point, when you build in VS2008 you'll get output such as this:

Project file contains ToolsVersion="4.0", which is not supported by this version of MSBuild. Treating the project as if it had ToolsVersion="3.5".

... but it will still work, in my experience. There may be some oddities if you use a lot of designers etc, but generally it seems to work pretty well.

Jon Skeet
In practice, how do the developers keep the 2008 and 2010 solution files in sync?
Jon Seigel
How often do you change solution files? Adding or removing a project is relatively rare. In my experience, you "just do it" - and if you forget to add a project to one when you add it to the other, the next person who needs it does so. Or you could have a tool to check that they both contain the same projects - that wouldn't take long to write. Basically I don't believe it's likely to be a problem in most cases.
Jon Skeet
That makes sense. Though I hate opening a project that doesn't build without changes, there probably isn't an easier way to do it.
Jon Seigel