C# 如何将 Visual Studio .NET 2008 解决方案转换为 Visual Studio .NET 2005?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/831289/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 03:23:17  来源:igfitidea点击:

How does one convert a Visual Studio .NET 2008 solution to Visual Studio .NET 2005?

c#visual-studio-2008visual-studio-2005solution

提问by James

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?

假设一个解决方案只包含类,并且这些类都是按照 .NET 2.0 规范编写的。如果要在 Visual Studio 2008 中打开、转换和保存该解决方案,是否可以稍后在 Visual Studio 2005 中重新打开该解决方案,并对 .SLN 文件进行一些最小修改?

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?

如果解决方案中包含的所有类都已写入 .NET 2.0 规范,是否有工具可以“下转换” 2008 年到 2005 年的 .SLN 文件?

采纳答案by Will Dean

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

通常,您对 .SLN 文件唯一需要做的就是更改文件顶部的版本号。

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.

您的 CS 项目文件也几乎可以,如果不是,可以调整它们,使其在 2005 和 2008 中都可以。

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

我们运行了一段时间,两个解决方案文件(05 和 08)共享同一组 CS 项目文件。

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

但请注意,您不能像这样在两个版本之间共享 VC 项目文件。

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

项目文件的“调整”如下:

CS Projects created on VS2008 will contain the line:

在 VS2008 上创建的 CS 项目将包含以下行:

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

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

VS2005会卡死这个,需要改成如下:

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

The latter will work with both 2005 and 2008.

后者将适用于 2005 和 2008。

回答by dirkgently

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.

没有直接的方法,如果您尝试,这是一项艰巨的任务。最简单的方法是创建一个新的 2005 项目并添加您的类。

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

对于初学者:这些是您会看到的差异:

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

.csproj 文件:(这些基于 MSBuild 架构)

(edit)

(编辑)

  • ToolsVersion
  • ProductVersion
  • ProjectVersion
  • 工具版本
  • 产品版本
  • 项目版本

(remove)

(消除)

  • OldToolsVersion
  • TargetFramework
  • 旧工具版本
  • 目标框架

.sln files: (no schema)

.sln 文件:(无架构)

  • Format Version 10.0
  • 格式版本 10.0

etc.

等等。

回答by Lasse V. Karlsen

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
  1. 2008年没有打开解决方案文件,因此永远不会升级它
  2. 不要针对相同的文件混合客户端版本(即坚持 2005,或者每个人都升级)
  3. 为 2005 和 2008 保留单独的解决方案文件,确保所有相同的项目都存在于两者中

Thanks to @Will Deanfor 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.

感谢@Will Dean提醒我项目文件确实可以共享。注意是2008年的编辑器碰过的,但是2005年以后可以打开。

回答by Jon Skeet

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.

如果你在 2008 年没有使用任何“花哨的”功能,根据我的经验,唯一改变的是几个地方的版本号。可以手动编辑(它位于文件 IIRC 的顶部)。至少值得一试。如果您使用了 VS2008 特定的功能(设计器等),它很可能不起作用,但对于简单的类库,我已经成功地做到了这一点。

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

你可能对我前段时间写的一篇关于 VS2005 和 VS2008 共存博文感兴趣。

回答by Eoin Campbell

You could try this. YMMV

你可以试试这个。青年会

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

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

我记得几个月前它发布在 Jon Skeets 的博客上,似乎得到了人们的赞许

回答by ggf31416

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

这里有一个转换器http://www.emmet-gray.com/Articles/ProjectConverter.htm(也适用于 VS 2010)。

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

还有http://www.dsmyth.net/wiki/Downloads_VS2008ToVS2005Patcher.ashx
(链接目前已损坏?)。

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

我也发现了这个http://www.codeplex.com/Vs2008BackMigration但我没有测试它。