Index: visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/Utility.cs |
diff --git a/visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/Utility.cs b/visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/Utility.cs |
index 2b2580538c44dc5431f147734036c339ff6eeb65..8dcdb02a67074f37c3b15ef69018943edb5e58d3 100644 |
--- a/visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/Utility.cs |
+++ b/visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/Utility.cs |
@@ -8,6 +8,7 @@ namespace NativeClientVSAddIn |
using System.Collections.Generic; |
using EnvDTE; |
+ using EnvDTE80; |
using Microsoft.VisualStudio.VCProjectEngine; |
/// <summary> |
@@ -22,8 +23,16 @@ namespace NativeClientVSAddIn |
/// <returns>True if project is a Visual C/C++ project.</returns> |
public static bool IsVisualCProject(Project proj) |
{ |
- string projectType = proj.Properties.Item("Kind").Value as string; |
- return projectType == "VCProject"; |
+ foreach (Property prop in proj.Properties) |
+ { |
+ if (prop.Name == "Kind") |
+ { |
+ string projectType = prop.Value as string; |
+ return projectType == "VCProject"; |
+ } |
+ } |
+ |
+ return false; |
} |
/// <summary> |
@@ -56,6 +65,36 @@ namespace NativeClientVSAddIn |
} |
/// <summary> |
+ /// Returns all VCConfigurations from the open solution that have the specified platform name. |
+ /// Note only VC++ projects are checked. |
+ /// </summary> |
+ /// <param name="dte">Visual studio main interface.</param> |
+ /// <param name="platformName">Name of the platform to get.</param> |
+ /// <returns>List of all matching VCConfigurations.</returns> |
+ public static List<VCConfiguration> GetPlatformVCConfigurations(DTE2 dte, string platformName) |
+ { |
+ var platformConfigs = new List<VCConfiguration>(); |
+ foreach (Project proj in dte.Solution.Projects) |
+ { |
+ if (Utility.IsVisualCProject(proj)) |
+ { |
+ VCProject vcproj = (VCProject)proj.Object; |
+ IVCCollection configs = vcproj.Configurations; |
+ |
+ foreach (VCConfiguration config in configs) |
+ { |
+ if (platformName.Equals(config.Platform.Name)) |
+ { |
+ platformConfigs.Add(config); |
+ } |
+ } |
+ } |
+ } |
+ |
+ return platformConfigs; |
+ } |
+ |
+ /// <summary> |
/// Extends the string class to allow checking if a string contains another string |
/// allowing a comparison type (such as case-insensitivity). |
/// </summary> |
@@ -89,6 +128,31 @@ namespace NativeClientVSAddIn |
} |
/// <summary> |
+ /// Helper function to properly dispose of a process object and ensure it is dead. The given |
+ /// reference is set to null afterwards. |
+ /// </summary> |
+ /// <param name="process">Process to kill. Reference is set to null afterwards.</param> |
+ public static void EnsureProcessKill(ref System.Diagnostics.Process process) |
+ { |
+ if (process == null) |
+ { |
+ return; |
+ } |
+ |
+ try |
+ { |
+ process.Kill(); |
+ } |
+ catch (System.InvalidOperationException) |
+ { |
+ // This happens if the process has already exited. |
+ } |
+ |
+ process.Dispose(); |
+ process = null; |
+ } |
+ |
+ /// <summary> |
/// Helper function for IsDescendantOfProcessHelper(). |
/// This function prevents an edge case where a process has a parent process ID |
/// that refers to a descendant of itself. This can occur when the parent of a process |