public static string GetProjectTypeGuids(Project proj) { string projectTypeGuids = ""; object service = null; IVsSolution solution = null; IVsHierarchy hierarchy = null; IVsAggregatableProject aggregatableProject = null; int result = 0; service = GetService(proj.DTE, typeof(IVsSolution)); solution = (IVsSolution)service; result = solution.GetProjectOfUniqueName(proj.UniqueName, out hierarchy); if (result == 0) { aggregatableProject = (IVsAggregatableProject)hierarchy; if (aggregatableProject != null) { result = aggregatableProject.GetAggregateProjectTypeGuids(out projectTypeGuids); } } return(projectTypeGuids); }
public string GetProjectTypeList(Project prj) { string projectTypeGuids = ""; object service = null; IVsSolution solution = null; IVsHierarchy hierarchy = null; IVsAggregatableProject aggregatableProject = null; int?result = 0; service = GetServiceObject(prj.DTE, typeof(IVsSolution)); solution = (IVsSolution)service; result = solution?.GetProjectOfUniqueName(prj.UniqueName, out hierarchy); if (result == 0) { try { aggregatableProject = (IVsAggregatableProject)hierarchy; result = aggregatableProject.GetAggregateProjectTypeGuids(out projectTypeGuids); } catch (Exception) { } } return(projectTypeGuids); }
private static bool IsCSharpProject(IVsProject project) { IVsAggregatableProject aggregatableProject = project as IVsAggregatableProject; if (aggregatableProject == null) { return(false); } string guidsString = null; if (ErrorHandler.Failed(ErrorHandler.CallWithCOMConvention(() => aggregatableProject.GetAggregateProjectTypeGuids(out guidsString)))) { return(false); } if (string.IsNullOrWhiteSpace(guidsString)) { return(false); } string[] guids = guidsString.Split(';'); foreach (var guidString in guids) { Guid guid; if (Guid.TryParse(guidString, out guid) && guid == CSharpProjectTypeGuid) { return(true); } } return(false); }
/// <summary> /// Determines whether [is share point project] [the specified h]. /// </summary> /// <param name="h">The h.</param> /// <returns> /// <c>true</c> if [is share point project] [the specified h]; otherwise, <c>false</c>. /// </returns> public static bool IsSharePointProject(IVsHierarchy h) { IVsAggregatableProject project = h as IVsAggregatableProject; if (project != null) { string guidString = null; project.GetAggregateProjectTypeGuids(out guidString); IEnumerable <Guid> guids = guidString.Split(';').Select(s => new Guid(s)); return(guids.Contains(SharePointProjectTypeID)); } return(false); }
/// <summary> /// Verifies if the given project is a Web Application. /// Checks the type GUIDs for that project. /// </summary> /// <param name="project">Project to verify</param> /// <returns>True if a subtype GUID matches the Web App Guid in Resources</returns> public static bool IsProjectWebApp(IVsProject project) { IVsAggregatableProject aggregatableProject = project as IVsAggregatableProject; if (aggregatableProject != null) { string projectTypeGuids; aggregatableProject.GetAggregateProjectTypeGuids(out projectTypeGuids); List <string> guids = new List <string>(projectTypeGuids.Split(';')); return(guids.Contains(Guids.GuidWebApplicationString)); } return(false); }
internal static string GetProjectTypesString(this IVsHierarchy project) { string projectTypeGuids = string.Empty; IVsAggregatableProject aggregatableProject = project as IVsAggregatableProject; if (aggregatableProject != null) { ErrorHandler.ThrowOnFailure(aggregatableProject.GetAggregateProjectTypeGuids(out projectTypeGuids)); } return(string.Join(" ", projectTypeGuids .Split(';') .Select(s => !String.IsNullOrEmpty(s) ? new Guid(s) : Guid.Empty) .Select(g => g.ToString("N")))); }
/// <include file='doc\FlavoredProject.uex' path='docs/doc[@for="FlavoredProject.SetInnerProject"]/*' /> /// <devdoc> /// This is were all QI for interface on the inner object should happen /// Then set the inner project /// wait for InitializeForOuter to be called to do the real initialization /// </devdoc> protected virtual void SetInnerProject(object inner) { // Keep a reference to each interface we want to call on the inner project // we must do it now as once we call SetInner the AddRef would be forwarded to ourselves innerVsAggregatableProject = (IVsAggregatableProject)inner; innerVsHierarchy = (IVsHierarchy)inner; innerVsUIHierarchy = (IVsUIHierarchy)inner; // As should return null without throwing in the event the base project does not implement the interface innerOleCommandTarget = inner as IOleCommandTarget; // Setup our menu command service if (this.serviceProvider == null) throw new NotSupportedException("serviceProvider should have been set before SetInnerProject gets called."); menuService = new OleMenuCommandService(this, innerOleCommandTarget); // Aggregate the project this.SetInner(inner); }
public static string GetPublishProfilePath(Project project) { IVsSolution solution = (IVsSolution)CloudFoundryVisualStudioPackage.GetGlobalService(typeof(IVsSolution)); if (solution == null) { return(string.Empty); } string projectFolder = GetProjectDirectory(project); IVsHierarchy hierarchy; int getProjectResult = solution.GetProjectOfUniqueName(project.UniqueName, out hierarchy); if (getProjectResult != VSConstants.S_OK) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Error retrieving project of unique name, error code: {0}", getProjectResult)); } IVsAggregatableProject aggregatable = (IVsAggregatableProject)hierarchy; string projectTypes = string.Empty; int projectTypeResult = aggregatable.GetAggregateProjectTypeGuids(out projectTypes); if (projectTypeResult != VSConstants.S_OK) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Error retrieving aggregate project types, error code: {0}", projectTypeResult)); } string result = System.IO.Path.Combine(projectFolder, "PublishProfiles"); if (projectTypes.ToUpperInvariant().Contains("{E24C65DC-7377-472B-9ABA-BC803B73C61A}")) { result = System.IO.Path.Combine(projectFolder, "App_Data", "PublishProfiles"); } if (projectTypes.ToUpperInvariant().Contains("{349C5851-65DF-11DA-9384-00065B846F21}")) { result = System.IO.Path.Combine(projectFolder, "Properties", "PublishProfiles"); } return(FileUtilities.PathAddBackslash(result)); }
/// <include file='doc\FlavoredProject.uex' path='docs/doc[@for="FlavoredProject.SetInnerProject"]/*' /> /// <devdoc> /// This is were all QI for interface on the inner object should happen /// Then set the inner project /// wait for InitializeForOuter to be called to do the real initialization /// </devdoc> protected virtual void SetInnerProject(object inner) { // Keep a reference to each interface we want to call on the inner project // we must do it now as once we call SetInner the AddRef would be forwarded to ourselves innerVsAggregatableProject = (IVsAggregatableProject)inner; innerVsHierarchy = (IVsHierarchy)inner; innerVsUIHierarchy = (IVsUIHierarchy)inner; // As should return null without throwing in the event the base project does not implement the interface innerOleCommandTarget = inner as IOleCommandTarget; // Setup our menu command service if (this.serviceProvider == null) { throw new NotSupportedException("serviceProvider should have been set before SetInnerProject gets called."); } menuService = new OleMenuCommandService(this, innerOleCommandTarget); // Aggregate the project this.SetInner(inner); }
static string GetProjectTypeGuids(EnvDTE.Project proj) { // Credits: https://www.mztools.com/articles/2007/MZ2007016.aspx string projectTypeGuids = ""; object service = GetService(proj.DTE, typeof(IVsSolution)); IVsSolution solution = (IVsSolution)service; IVsHierarchy hierarchy; int result = solution.GetProjectOfUniqueName(proj.UniqueName, out hierarchy); if (result == 0) { IVsAggregatableProject aggregatableProject = hierarchy as IVsAggregatableProject; if (aggregatableProject != null) { result = aggregatableProject.GetAggregateProjectTypeGuids(out projectTypeGuids); } } return(projectTypeGuids); }