How does one convert a Visual Studio .NET 2008 sol

2019-05-14 22:18发布

问题:

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?

回答1:

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.



回答2:

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.



回答3:

Here there is a converter http://www.emmet-gray.com/Articles/ProjectConverter.htm (works with VS 2010 also).

There is also http://www.dsmyth.net/wiki/Downloads_VS2008ToVS2005Patcher.ashx
(link currently broken?).

I also found this http://www.codeplex.com/Vs2008BackMigration but I didn't test it.



回答4:

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.



回答5:

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



回答6:

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.