views:

3449

answers:

6

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?

A: 

There's no direct way, and it's a tall order if you try. The simplest way would be to create a new 2005 project and add your classes.

For starters: these are the differences that you'd see:

.csproj files: (these are based on MSBuild schema)

(edit)

  • ToolsVersion
  • ProductVersion
  • ProjectVersion

(remove)

  • OldToolsVersion
  • TargetFramework

.sln files: (no schema)

  • Format Version 10.0

etc.

dirkgently
This isn't true. CS *projects* can be shared between the two versions.
Will Dean
The OP was asking about solution files. I have added some more detail to my answer that tells you why it is difficult. (I never said it's impossible.)
dirkgently
+2  A: 

Yes, it is possible, if you "downgrade" the solution files.

No, there is no such tool that I know of, and I've looked.

You have three options:

  1. Not open the solution file in 2008, and thus never upgrade it
  2. Not mix client versions against the same files (ie. stick to 2005, or everyone upgrade)
  3. Keep separate solution files for 2005 and 2008, make sure all the same projects are present in both

Thanks to @Will Dean for reminding me that project files can indeed be shared. Note that they are touched by the 2008 editor, but they can be opened in 2005 afterwards.

Lasse V. Karlsen
For CS projects, it's not necessary to keep separate projects, you can share them between 2005 and 2008
Will Dean
Projects yes, Solution files no.
Russ
I actually ran into a situation where a C# project (not solution) from Visual Studio 2008 was unable to load in Visual Studio 2005. The error was: "The imported project "C:\Microsoft.CSharp.targets" was not found."
James
+3  A: 

If you're not using any "fancy" features in 2008, in my experience the only thing which changes is the version number in a couple of places. That can be manually edited (it's at the top of the file IIRC). It's at least worth a try. If you're used VS2008-specific features (designers etc) it may well not work but for simple class libraries I've had success doing this.

You may be interested in a blog post about VS2005 and VS2008 co-existing that I wrote a while ago.

Jon Skeet
+5  A: 

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.

Will Dean
+1  A: 

You could try this. YMMV

http://www.emmet-gray.com/Articles/ProjectConverter.htm

I remember it was posted on Jon Skeets blog a few months back and seemed to get a thumbs up from people

Eoin Campbell
+2  A: 

Here there is a converter http://www.emmet-gray.com/Articles/ProjectConverter.htm
There is also http://www.dsmyth.net/wiki/Downloads_VS2008ToVS2005Patcher.ashx
I also found this http://www.codeplex.com/Vs2008BackMigration but I didn't test it.

ggf31416