Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrade Visual Studio solution and project files programmatically

I have a lot of visual studio projects which are delivered to the customer using installer. After the installation all project and solution files should be of the latest installed visual studio version. Is there any way to convert a lot of projects fast?

I've tried following:

1) parsing the files and replacing different properties like ToolsVersion etc. It's fast but not reliable and should be changed for every new Visual Studio which comes to the market (yearly from now AFAIK)

2) Using devenv upgrade feature, reliable but VERY slow:

string[] files = Directory.GetFiles(@"c:\MyTmp", "*.sln", SearchOption.AllDirectories);
foreach (string file in files)
{
    Process process = new Process();
    process.StartInfo.FileName = pathToTheLatestVS;
    process.StartInfo.Arguments = "/Upgrade \"" + file + "\"";
    process.Start();
    process.WaitForExit();
}

3) Tried to create a hidden instance of VS and manipulate solutions from there as described here, but no luck.

So is that possible to upgrade many project/solution files to a specific Visual Studio version in fast and reliable way?

like image 774
VladL Avatar asked Jun 12 '13 10:06

VladL


1 Answers

Let me present you a different view than the 2 you presented. The fact that an upgrade is slow is that all kinds of checks are performed on the projects/solutions that you attempt to upgrade. An 'Upgrade Report' is generated to provide feedback on those checks. This is information that should not be ignored since it provides remedies on the mentioned issues.

You state that you deploy the projects/solutions via an installer. Presuming that you have a development team/tools that are up-to-date you could perform the upgrades as part of your installer design/development. Why would you not perform the upgrades yourself and include project files in your installer. During installation you would install the version of the project/solutions files that matches the target platform.

like image 197
Vapour in the Alley Avatar answered Nov 05 '22 18:11

Vapour in the Alley