How to have the same VS project with multiple .csproj files depending on the VS version?

≡放荡痞女 提交于 2019-12-24 09:27:53

问题


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).


回答1:


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 (Solution.sln)
    • Project_1 (Project_1.csproj)
    • Project_2 (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.



来源:https://stackoverflow.com/questions/5061979/how-to-have-the-same-vs-project-with-multiple-csproj-files-depending-on-the-vs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!