Getting project, solution files for different versions of Visual Studio - visual-studio

I have a suite of C++ programs in Visual Studio 2012. I want to provide project and solution files for Visual Studio 2013 and 2015 as well (and later versions as they come), in the appropriate subfolders.
Is there a way to get Visual Studio to leave the old project and solution files, while adding the new ones?

No, it will convert the older version to a new one (or at least try to) on the first open attempt. But you can easily achieve the desired effect by manually creating 3 sets of project/solution files, each corresponding to different version.
Note though it's probably not a good idea to have a SW compatible with different compilers/IDEs. There are many differences between different compilers, the changes between VS2013 and VS2015 are especially extensive. Most likely you won't be able to immediately compile without errors on both of them. Some errors you'll be able to fix to satisfy both compilers but there are some changes that aren't backwards compatible, so you'll end up with multiple #ifdefs in the code which is not desirable from design and maintenance aspects. Also, maintaining multiple versions of project/solution files will be a pain in the ass.

Related

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

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

How can I open a Visual Studio 2008 project in Visual Studio 2010 and leave it in 2008 format?

Sometimes I do consultancy work for companies that are still using Visual Studio 2008, but I have 2010 installed.
I assumed (yes, assumption is the mother, father brother and sister of all f-ups!) that I would be able to open 2008 projects in 2010 without having to upgrade them. However, it appears that this is not the case?
Unfortunately, choosing to compile for .NET 3.5 wont solve this problem as the original developers will need to continue to develop the same projects in 2008
You can't leave a project in VS2008 format and there's no automatic way to downgrade a VS2010 project to a VS2008 project.
There are a number of differences to the files:
<Project ToolsVersion="3.5" ...
becomes:
<Project ToolsVersion="4.0" ...
The <ProductVersion> changes from 9.0.30729 to 8.0.30703 (though I am only using the 2010 Express editions at the moment so this might be different for the full version).
Alternatively you could upgrade the project on your machine and just copy back the source files. However, this would require more work if you added/removed any project files as this would have to be repeated on a machine running VS2008.
Unfortunately, I don't think there is a backward compatibility option for VS2010.
What I have been doing is upgrading the VS2008 project to 2010, and leaving backup copies of the project and solution files. I then rename all of the upgraded files to project_name_vs2010.* and rename the backup files back to the original name, since I'm the only developer using 2010. The downside is that any changes you make to the project or solution need to be redone inside of VS2008 (or manually edit the XML if you don't have a copy of 2008) before you push your changes. The positive is that all source files will work in both versions thanks to VS2010's multi-targeting. You'll definitely need to keep the compiler setting to 3.5 in order to keep all the source files compatible.
I faced this same issue with 2005 to 2008. If you aren't using anything that is not supported in the earlier version, such as .Net 4, then all you need to do is revert changes VS makes to the .proj file to then open it again in 2008. This is very annoying to have to do repeatedly but I think it is basically your only option.
You Can't.
However, you can have multiple solutions (one for 2010, one for 2008) which each reference the projects. The project files themselves don't have to change.
If you go this route, you have to make sure the project targets are no higher than .Net 3.5.

Work with VS 2010 on a project for VS 2005

I have a project on SourceSafe that the team work with VS 2005.
I have installed VS2010 and like some features of this version.
Is there a way that I keep the project to day with SourceSafe, but however work locally with VS2010.
Say, I could not add new files to solution, but at least obtain, modify and archive the existing ones.
You can update all of the source files pretty safely unless you're adding code that is new since VS 2005. The main difference between the VS versions is in the project, and the solution files. What you can do is make your local project and solution files writable, and then use your source control to modify the source files. When all is said and done though you'll want to build it in 2005 (with the SourceSafe versions of the project and solution files) to make sure it all still works.
Also note that the conversion utility in Visual Studio that converts projects from previous VS versions is only intended to convert projects from the previous version. Since VS 2010's previous version is VS 2008 and not VS 2005 you may have to perform manual changes on your solution and project settings to get everything to build. The main thing that comes to mind is how global include directories are handled. If you have access to VS 2008 convert it to that first, and then to VS 2010.
Besides targetting the 2.0 framework VS2010 will still let you use new language features so you have to be careful.
And as Ben Burnett said, the sourcesafe binding doens't have to be a problem as long as you don't check out project and solution files. You can remove the read only flag from them so VS2010 can edit them, but they don't need be be checked into sourcesafe.
But I really wonder which feature you like so much about VS2010 that you want to restrict yourself to not be able to add, remove or rename files from your project.

How can I stop Visual Studio automatically upgrading projects?

I'd like to give VS2k10 a shot, but I'm in a VS2k8 environment. I compared the upgraded project files in VS2k10 and the only difference was the updated version number - how can I stop VS from doing this?
Probably the only way to open the VS 2008 projects safely in VS 2010 will be to make a copy and open the copy in VS 2010. In my experience, it's impossible to revert back once you have opened a specific project in a later version of VS unless you feel like changing the version number in the project files.
This was true with the 2003 to 2005 switch, and also with the 2005 to 2008 switch.
It also does this for some 2K8 SP1 in some cases IIRC. How about just not checking in csproj files from 2k8 - you never know when you're going to hit a more complex case where you are actually hitting something 2kA specific, and by first making sure everything still works in 2k8 you'll prevent team confusion.
You can't stop VS from trying to upgrade the project. When VS detects that the project file is not high enough for it's version, it will force an upgrade. If you cancel it will then not allow you to open the project.
I find the best approach here is to use two project files; 1 for each version of visual studio. I usually just copy all of the project files, open one and rebuild the solution.

Working with different versions/branches of the same Visual Studio 2005 solution

This is kind of a usability question for using VS2005: I have different branches of the same Visual Studio 2005 solution checked out from version control. The solution and project files are also under version control. On my development workstation, I sometimes have multiple instances of Visual Studio opened on a different version or branch each. They all show up under the same name in the window title and the taskbar, which makes it hard to switch to the correct one etc. (The same goes for the list of recently opened projects in the startup page, but I rarely use that, anyway.)
I tried to find a way to only change the name displayed while not running into too much trouble with source control, but Visual Studio 2005 seems to take the solution name from the name of the SLN file itself, not from some attribute inside of it.
It would already help to have Visual Studio show the full path to the solution file in the title bar, but I haven't found a way to do that, either.
How do you handle different versions from the same solution?
Use the (free) VSCommands plugin:
http://geekswithblogs.net/deadlydog/archive/2011/04/29/friendly-visual-studio-solution-names-for-branches.aspx
I guess it only works when using different folders for different branches (not SVN switching), but still, it's good stuff.
Same issue here. VS has bad support for equally named solutions in different directories.
A somewhat hacky workaround: http://www.helixoft.com/blog/archives/32
There's an ideal extension for your problem, but you must use at least VS 2010:
http://visualstudiogallery.msdn.microsoft.com/f3f23845-5b1e-4811-882f-60b7181fa6d6
It changes the title bar, so must not rename solutions or files.
I know that is an old post, but perhaps you have now a newer VS version :-)
Why don't you rename the solution file on your branches, e.g. MySolution-branchXY.sln?
Update:
I'm not sure I understand your comment.
As soon as you have branched your solution, you have two independent versions of each file: one on the trunk (or source branch) and one on the new branch. The two files simply share a common history, but you are free to change them independently on both branches. So you can rename the solution in your branch.

Resources