summaryrefslogtreecommitdiff
path: root/indra/tools
diff options
context:
space:
mode:
authorMark Palange <palange@lindenlab.com>2008-06-06 00:18:26 +0000
committerMark Palange <palange@lindenlab.com>2008-06-06 00:18:26 +0000
commit015104ac24f046d5df4d9cc085420ce832168785 (patch)
tree4fd1ddb8ee09ddffc53e368be050d8f955902f48 /indra/tools
parent84fe582c1ea5ddd073a71064ffa9aa72fa35d7ca (diff)
DEV-16285 - Give vstool.exe better error reporting output.
Diffstat (limited to 'indra/tools')
-rwxr-xr-xindra/tools/vstool/VSTool.exebin24576 -> 24576 bytes
-rw-r--r--indra/tools/vstool/main.cs305
2 files changed, 180 insertions, 125 deletions
diff --git a/indra/tools/vstool/VSTool.exe b/indra/tools/vstool/VSTool.exe
index c568c8dd6a..2d87971111 100755
--- a/indra/tools/vstool/VSTool.exe
+++ b/indra/tools/vstool/VSTool.exe
Binary files differ
diff --git a/indra/tools/vstool/main.cs b/indra/tools/vstool/main.cs
index 0cd57b6b84..1dc0d2c1c6 100644
--- a/indra/tools/vstool/main.cs
+++ b/indra/tools/vstool/main.cs
@@ -16,43 +16,70 @@ namespace VSTool
{
public static object GetProperty(object from_obj, string prop_name)
{
- Type objType = from_obj.GetType();
- return objType.InvokeMember(
- prop_name,
- BindingFlags.GetProperty, null,
- from_obj,
- null);
+ try
+ {
+ Type objType = from_obj.GetType();
+ return objType.InvokeMember(
+ prop_name,
+ BindingFlags.GetProperty, null,
+ from_obj,
+ null);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Error getting property: \"{0}\"", prop_name);
+ Console.WriteLine(e.Message);
+ throw e;
+ }
}
public static object SetProperty(object from_obj, string prop_name, object new_value)
{
- object[] args = { new_value };
- Type objType = from_obj.GetType();
- return objType.InvokeMember(
- prop_name,
- BindingFlags.DeclaredOnly |
- BindingFlags.Public |
- BindingFlags.NonPublic |
- BindingFlags.Instance |
- BindingFlags.SetProperty,
- null,
- from_obj,
- args);
+ try
+ {
+ object[] args = { new_value };
+ Type objType = from_obj.GetType();
+ return objType.InvokeMember(
+ prop_name,
+ BindingFlags.DeclaredOnly |
+ BindingFlags.Public |
+ BindingFlags.NonPublic |
+ BindingFlags.Instance |
+ BindingFlags.SetProperty,
+ null,
+ from_obj,
+ args);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Error setting property: \"{0}\"", prop_name);
+ Console.WriteLine(e.Message);
+ throw e;
+ }
}
public static object CallMethod(object from_obj, string method_name, params object[] args)
{
- Type objType = from_obj.GetType();
- return objType.InvokeMember(
- method_name,
- BindingFlags.DeclaredOnly |
- BindingFlags.Public |
- BindingFlags.NonPublic |
- BindingFlags.Instance |
- BindingFlags.InvokeMethod,
- null,
- from_obj,
- args);
+ try
+ {
+ Type objType = from_obj.GetType();
+ return objType.InvokeMember(
+ method_name,
+ BindingFlags.DeclaredOnly |
+ BindingFlags.Public |
+ BindingFlags.NonPublic |
+ BindingFlags.Instance |
+ BindingFlags.InvokeMethod,
+ null,
+ from_obj,
+ args);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Error calling method \"{0}\"", method_name);
+ Console.WriteLine(e.Message);
+ throw e;
+ }
}
};
@@ -77,6 +104,8 @@ namespace VSTool
static string startup_project = null;
static string config = null;
+ static object dte = null;
+ static object solution = null;
/// <summary>
/// The main entry point for the application.
@@ -86,125 +115,98 @@ namespace VSTool
{
bool need_save = false;
- parse_command_line(args);
-
- Console.WriteLine("Opening solution: {0}", solution_name);
-
- bool found_open_solution = true;
-
- Console.WriteLine("Looking for existing VisualStudio instance...");
-
- // Get an instance of the currently running Visual Studio .NET IDE.
- object dte = null;
-
- // dte = (EnvDTE.DTE)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.7.1");
- string full_solution_name = System.IO.Path.GetFullPath(solution_name);
- if (false == use_new_vs)
- {
- dte = GetIDEInstance(full_solution_name);
- }
-
- object sol = null;
-
- if (dte == null)
+ try
{
- try
- {
- Console.WriteLine(" Didn't find open solution, now opening new VisualStudio instance...");
- Console.WriteLine(" Reading .sln file version...");
- string version = GetSolutionVersion(full_solution_name);
+ parse_command_line(args);
- Console.WriteLine(" Opening VS version: {0}...", version);
- string progid = GetVSProgID(version);
+ Console.WriteLine("Opening solution: {0}", solution_name);
- Type objType = Type.GetTypeFromProgID(progid);
- dte = System.Activator.CreateInstance(objType);
-
- Console.WriteLine(" Opening solution...");
+ bool found_open_solution = GetDTEAndSolution();
- sol = ViaCOM.GetProperty(dte, "Solution");
- object[] openArgs = {full_solution_name};
- ViaCOM.CallMethod(sol, "Open", openArgs);
- }
- catch( Exception e )
+ // Walk through all of the projects in the solution
+ // and list the type of each project.
+ foreach (DictionaryEntry p in projectDict)
{
- Console.WriteLine(e.Message);
- Console.WriteLine("Quitting do error opening: {0}", full_solution_name);
- return;
- }
- found_open_solution = false;
- }
-
- if (sol == null)
- {
- sol = ViaCOM.GetProperty(dte, "Solution");
- }
-
- // Walk through all of the projects in the solution
- // and list the type of each project.
- foreach(DictionaryEntry p in projectDict)
- {
- string project_name = (string)p.Key;
- string working_dir = (string)p.Value;
- if(SetProjectWorkingDir(sol, project_name, working_dir))
- {
- need_save = true;
+ string project_name = (string)p.Key;
+ string working_dir = (string)p.Value;
+ if (SetProjectWorkingDir(solution, project_name, working_dir))
+ {
+ need_save = true;
+ }
}
- }
- if(config != null)
- {
- try
- {
- object solBuild = ViaCOM.GetProperty(sol, "SolutionBuild");
- object solCfgs = ViaCOM.GetProperty(solBuild, "SolutionConfigurations");
- object[] itemArgs = { (object)config };
- object solCfg = ViaCOM.CallMethod(solCfgs, "Item", itemArgs);
- ViaCOM.CallMethod(solCfg, "Activate", null);
- need_save = true;
- }
- catch( Exception e )
+ if (config != null)
{
- Console.WriteLine(e.Message);
+ try
+ {
+ object solBuild = ViaCOM.GetProperty(solution, "SolutionBuild");
+ object solCfgs = ViaCOM.GetProperty(solBuild, "SolutionConfigurations");
+ object[] itemArgs = { (object)config };
+ object solCfg = ViaCOM.CallMethod(solCfgs, "Item", itemArgs);
+ ViaCOM.CallMethod(solCfg, "Activate", null);
+ need_save = true;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
}
- }
- if (startup_project != null)
- {
- try
+ if (startup_project != null)
{
- // You need the 'unique name of the project to set StartupProjects.
- // find the project by generic name.
- object prjs = ViaCOM.GetProperty(sol, "Projects");
- object count = ViaCOM.GetProperty(prjs, "Count");
- for(int i = 1; i <= (int)count; ++i)
+ try
{
- object[] itemArgs = { (object)i };
- object prj = ViaCOM.CallMethod(prjs, "Item", itemArgs);
- object prjName = ViaCOM.GetProperty(prj, "Name");
- if (0 == string.Compare((string)prjName, startup_project, ignore_case))
+ // You need the 'unique name of the project to set StartupProjects.
+ // find the project by generic name.
+ object prjs = ViaCOM.GetProperty(solution, "Projects");
+ object count = ViaCOM.GetProperty(prjs, "Count");
+ for (int i = 1; i <= (int)count; ++i)
{
- object solBuild = ViaCOM.GetProperty(sol, "SolutionBuild");
- ViaCOM.SetProperty(solBuild, "StartupProjects", ViaCOM.GetProperty(prj, "UniqueName"));
- need_save = true;
- break;
+ object[] itemArgs = { (object)i };
+ object prj = ViaCOM.CallMethod(prjs, "Item", itemArgs);
+ object prjName = ViaCOM.GetProperty(prj, "Name");
+ if (0 == string.Compare((string)prjName, startup_project, ignore_case))
+ {
+ object solBuild = ViaCOM.GetProperty(solution, "SolutionBuild");
+ ViaCOM.SetProperty(solBuild, "StartupProjects", ViaCOM.GetProperty(prj, "UniqueName"));
+ need_save = true;
+ break;
+ }
}
}
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
}
- catch (Exception e)
+
+ if (need_save)
{
- Console.WriteLine(e.Message);
+ if (found_open_solution == false)
+ {
+ ViaCOM.CallMethod(solution, "Close", null);
+ }
}
}
-
- if(need_save)
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ finally
{
- if(found_open_solution == false)
+ if (solution != null)
{
- ViaCOM.CallMethod(sol, "Close", null);
+ Marshal.ReleaseComObject(solution);
+ solution = null;
+ }
+
+ if (dte != null)
+ {
+ Marshal.ReleaseComObject(dte);
+ dte = null;
}
- Console.WriteLine("Finished!");
}
+ Console.WriteLine("Finished!");
}
public static bool parse_command_line(string[] args)
@@ -285,6 +287,59 @@ namespace VSTool
return true;
}
+ public static bool GetDTEAndSolution()
+ {
+ bool found_open_solution = true;
+
+ Console.WriteLine("Looking for existing VisualStudio instance...");
+
+ // Get an instance of the currently running Visual Studio .NET IDE.
+ // dte = (EnvDTE.DTE)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.7.1");
+ string full_solution_name = System.IO.Path.GetFullPath(solution_name);
+ if (false == use_new_vs)
+ {
+ dte = GetIDEInstance(full_solution_name);
+ }
+
+ if (dte == null)
+ {
+ try
+ {
+ Console.WriteLine(" Didn't find open solution, now opening new VisualStudio instance...");
+ Console.WriteLine(" Reading .sln file version...");
+ string version = GetSolutionVersion(full_solution_name);
+
+ Console.WriteLine(" Opening VS version: {0}...", version);
+ string progid = GetVSProgID(version);
+
+ Type objType = Type.GetTypeFromProgID(progid);
+ dte = System.Activator.CreateInstance(objType);
+
+ Console.WriteLine(" Opening solution...");
+
+ solution = ViaCOM.GetProperty(dte, "Solution");
+ object[] openArgs = { full_solution_name };
+ ViaCOM.CallMethod(solution, "Open", openArgs);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ Console.WriteLine("Quitting do to error opening: {0}", full_solution_name);
+ solution = null;
+ dte = null;
+ return found_open_solution;
+ }
+ found_open_solution = false;
+ }
+
+ if (solution == null)
+ {
+ solution = ViaCOM.GetProperty(dte, "Solution");
+ }
+
+ return found_open_solution;
+ }
+
/// <summary>
/// Get the DTE object for the instance of Visual Studio IDE that has
/// the specified solution open.