C# – How does one convert a Visual Studio .NET 2008 solution to Visual Studio .NET 2005

csolutionvisual-studio-2005visual-studio-2008

Assume that a solution only contains classes and that those classes are all written to .NET 2.0 specifications. If that solution were to be opened, converted and saved in Visual Studio 2008, would it be possible to reopen the solution later in Visual Studio 2005 with some minimal modifications to the .SLN file?

How would one go about doing that?

Is there a tool that will "down convert" .SLN files from 2008 to 2005 if all of the classes contained within the solution are already written to .NET 2.0 specifications?

Best Answer

Uusally, the only thing you need to do with .SLN files is to change the version number at the top of the file.

Your CS project files will also be almost OK, and if they're not, it's possible to tweak them so that they are OK with both 2005 and 2008.

We ran for a while with two solution files (05 and 08) sharing the same set of CS project files.

Be aware though, that you can't share VC project files between the two versions like this.

The 'tweak' for the project files is as follows:

CS Projects created on VS2008 will contain the line:

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

VS2005 will choke on this, and you need to change it to the following:

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

The latter will work with both 2005 and 2008.