private IEnumerable <Guid> GetAggregateProjectKindsIterator(IVsHierarchy hierarchy) { // TODO: is this relevant for core projects? IVsAggregatableProjectCorrected aggregatableProject = hierarchy as IVsAggregatableProjectCorrected; if (aggregatableProject == null) { yield break; } string guidStrings; if (ErrorHandler.Succeeded(aggregatableProject.GetAggregateProjectTypeGuids(out guidStrings))) { foreach (var guidStr in guidStrings.Split(';')) { Guid guid; if (Guid.TryParse(guidStr, out guid)) { yield return(guid); } } } }
public IEnumerable <Guid> GetAggregateProjectKinds(IVsHierarchy hierarchy) { if (hierarchy == null) { throw new ArgumentNullException(nameof(hierarchy)); } IVsAggregatableProjectCorrected aggregatableProject = hierarchy as IVsAggregatableProjectCorrected; if (aggregatableProject == null) { yield break; } string guidStrings; if (ErrorHandler.Succeeded(aggregatableProject.GetAggregateProjectTypeGuids(out guidStrings))) { foreach (var guidStr in guidStrings.Split(';')) { Guid guid; if (Guid.TryParse(guidStr, out guid)) { yield return(guid); } } } }
public string[] GetProjectTypeGuids(EnvDTE.Project proj) { ThreadHelper.ThrowIfNotOnUIThread(); string projectTypeGuids = string.Empty; object service = null; Microsoft.VisualStudio.Shell.Interop.IVsSolution solution = null; Microsoft.VisualStudio.Shell.Interop.IVsHierarchy hierarchy = null; IVsAggregatableProjectCorrected aggregatableProject = null; int result = 0; service = GetService(proj.DTE, typeof(SVsSolution)); solution = (Microsoft.VisualStudio.Shell.Interop.IVsSolution)service; result = solution.GetProjectOfUniqueName(proj.UniqueName, out hierarchy); if (result == 0) { aggregatableProject = hierarchy as IVsAggregatableProjectCorrected; if (aggregatableProject != null) { result = aggregatableProject.GetAggregateProjectTypeGuids(out projectTypeGuids); } } if (String.IsNullOrWhiteSpace(projectTypeGuids)) { return(null); } return(projectTypeGuids.Split(';')); }
private LaunchType GetProjectLaunchType(Project project) { IVsSolution solution = (IVsSolution)Package.GetGlobalService(typeof(SVsSolution)); IVsHierarchy hierarchy = null; solution.GetProjectOfUniqueName(project.UniqueName, out hierarchy); IVsAggregatableProjectCorrected AP = hierarchy as IVsAggregatableProjectCorrected; string projTypeGuids = null; AP.GetAggregateProjectTypeGuids(out projTypeGuids); projTypeGuids = projTypeGuids.ToUpper(); if (projTypeGuids.Contains(WEB_SITE_PROJECT_TYPE_GUID.ToUpper())) { return(LaunchType.WebSite); } else if (projTypeGuids.Contains(WEB_APPLICATION_PROJECT_SUBTYPE_GUID.ToUpper())) { return(LaunchType.WebApplication); } return(LaunchType.Assembly); }
/// <devdoc> /// This must be delegetated to the inner most project /// </devdoc> int IVsAggregatableProjectCorrected.GetAggregateProjectTypeGuids(out string projectTypeGuids) { if (_innerVsAggregatableProject == null) { throw new NotSupportedException(); } return(_innerVsAggregatableProject.GetAggregateProjectTypeGuids(out projectTypeGuids)); }
/// <summary> /// Get weather the project is portable class library or not. /// </summary> /// <param name="project"></param> /// <param name="solution"></param> /// <returns></returns> public static bool IsPclProject(this Project project, IVsSolution solution) { solution.GetProjectOfUniqueName(project.UniqueName, out IVsHierarchy hierarchy); IVsAggregatableProjectCorrected ap = hierarchy as IVsAggregatableProjectCorrected; string projTypeGuids = null; ap?.GetAggregateProjectTypeGuids(out projTypeGuids); return(projTypeGuids == Constants.PclProjectTypeGuids); }
private LaunchType GetProjectLaunchType(Project project) { try { IVsSolution solution = (IVsSolution)Package.GetGlobalService(typeof(SVsSolution)); IVsHierarchy hierarchy = null; solution.GetProjectOfUniqueName(project.UniqueName, out hierarchy); IVsAggregatableProjectCorrected AP = hierarchy as IVsAggregatableProjectCorrected; string projTypeGuids = null; // e.g. .NET core applications are not aggregable if (AP != null) { AP.GetAggregateProjectTypeGuids(out projTypeGuids); projTypeGuids = projTypeGuids.ToUpper(); if (projTypeGuids.Contains(WEB_SITE_PROJECT_TYPE_GUID.ToUpper())) { return(LaunchType.WebSite); } if (projTypeGuids.Contains(WEB_APPLICATION_PROJECT_SUBTYPE_GUID.ToUpper())) { return(LaunchType.WebApplication); } } if (new AssemblyLauchConfig(project).IsValid()) { return(LaunchType.Assembly); } } catch (Exception ex) { context.log(Context.LOG_ERROR + "Error while resolving project launch type: " + ex); } return(LaunchType.Unknown); }