如何根据 VS 版本拥有具有多个 .csproj 文件的同一个 VS 项目?
有时我看到一个解决方案,该解决方案中的每个项目最多包含三个 .csproj 文件。像这样的东西:
Project.UI.2005.csproj
Project.UI.2008.csproj
Project.UI.2010.csproj
与 .sln
文件相同:
ProjectSolution.2005.sln
ProjectSolution.2008.sln
ProjectSolution.2010.sln
因此,如果您复制解决方案并希望使用 VS2005 打开它,则只需打开 Project.UI.2005.csproj 或
ProjectSolution.2005.sln
。
创建这 3 个(或 2 个)文件的最佳方法是什么,以便能够在多个版本的 Visual Studio 中打开相同的解决方案?
也许唯一的方法是手动修改.sln
/.csproj
。如果是这样:
如何正确修改这些文件,以免解决方案崩溃?
我想这样做,因为有时我使用VS2010开发应用程序并在部署源代码时代码给我的客户,他们无法在VS2008中打开它,然后我必须做一些调整。
注意:
我知道如果我使用仅包含在 .NET Framework v4.0 或类似版本中的功能,将会出现引用和编译问题。假设解决方案中的所有项目都在 .NET Framework 2.0 下编译(在项目属性中指定)。
Sometimes I've seen a solution that includes up to three .csproj files for each project in the solution. Something like this:
Project.UI.2005.csproj
Project.UI.2008.csproj
Project.UI.2010.csproj
and the same with .sln
files:
ProjectSolution.2005.sln
ProjectSolution.2008.sln
ProjectSolution.2010.sln
So if you copy the solution and want to open it using VS2005, you just need to open Project.UI.2005.csproj
or ProjectSolution.2005.sln
.
What is the best way of creating those 3 (or 2) files, in order to be able to open the same solution in multiple versions of Visual Studio?
Maybe the only way of doing this is modifying manually the .sln
/.csproj
. If so:
How can I modify those files correctly so I won't crash the solution?
I want to do this because sometimes I develop applications using VS2010 and when deploying the source code to my customers, they can't open it in VS2008, and then I have to do some tweaks.
Note:
I know there will be referencing and compiling problems if I use features only included in .NET Framework v4.0, or similar. Let's suppose all the projects in the solution are compiling under .NET Framework 2.0 (specified in the project properties).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最终结束了为此开发的一个小应用程序。
我仍在测试它,但到目前为止它运行良好。
您需要做的就是选择要转换的 .sln 文件,并指定转换涉及的版本,它会为您完成所有工作。
如果您有 VS 2010 项目:
Solution.sln
)Project_1.csproj
)Project_2.csproj
)并且您想要降级版本(至 2008),它将保留这些文件,并创建:
Solution.2008.sln
Project_1.2008.csproj
Project_2.2008.csproj
您将能够使用 打开
Solution.2008.sln
>Visual Studio 2008没有问题。一旦完成,我将在这里分享可执行文件和源代码。
I finally ended developing a small application do to this.
I'm still testing it, but it is working good so far.
All you need to do is, select the
.sln
file you want to convert, and specify the versions involved in the conversion, and it will do all the work for you.If you have a VS 2010 project:
Solution.sln
)Project_1.csproj
)Project_2.csproj
)and you want downgrade the version (to 2008), it will keep those files, and also create:
Solution.2008.sln
Project_1.2008.csproj
Project_2.2008.csproj
And you will be able to open
Solution.2008.sln
with Visual Studio 2008 without problems.As soon as I finish it, I'll share executables and sources here.