-
Notifications
You must be signed in to change notification settings - Fork 17
/
UpgradeVSProjects.cs
39 lines (35 loc) · 1.51 KB
/
UpgradeVSProjects.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace ProjectConverter
{
public class UpgradeVSProjects
{
/// <summary>
/// Executes the Visual Studio Solution Upgrade
/// by directly invoking the Visual Studio devenv.exe executable
/// and passing the /Upgrade switch
/// </summary>
/// <param name="strDevEnvExePath">string path to the Visual Studio devenv.exe executable</param>
/// <param name="strVSSolnPath">string path to the Visual Studio solution</param>
/// <param name="strStdOutput">out parameter for standard output</param>
public static string DevEnvUpgrade(string strDevEnvExePath, string strVSSolnPath, out string strStdOutput)
{
ProcessStartInfo procInfo = new ProcessStartInfo(strDevEnvExePath);
procInfo.Arguments = string.Format("{0} {1}", "/Upgrade", strVSSolnPath);
procInfo.UseShellExecute = false; //required to use RedirectStandardOutput property
procInfo.RedirectStandardOutput = true;
procInfo.RedirectStandardError = true;
Process p = new Process();
p.StartInfo = procInfo;
p.Start();
// Read the output stream first and then wait.
strStdOutput = p.StandardOutput.ReadToEnd();
string errOutput = p.StandardError.ReadToEnd();
p.WaitForExit();
return errOutput;
}//method: DevEnvUpgrade()
}
}