/// <summary> /// Get export /// </summary> internal static T GetExport <T>(IVsHierarchy hier) { using (var sp = new Shell.ServiceProvider((OLE.Interop.IServiceProvider)hier.GetDTEProject().DTE)) { IComponentModel compMode = sp.GetService <IComponentModel, SComponentModel>(); return(compMode.DefaultExportProvider.GetExport <T>().Value); } }
/// <summary> /// Convenient way to get to the UnconfiguredProject from the hierarchy /// </summary> public static IVsBrowseObjectContext GetBrowseObjectContext(this IVsHierarchy hierarchy) { VsAppShell.Current.AssertIsOnMainThread(); var context = hierarchy as IVsBrowseObjectContext; if (context == null) { var dteProject = hierarchy.GetDTEProject(); context = dteProject?.Object as IVsBrowseObjectContext; } return(context); }
public IReadOnlyList <string> GetSolutionBuildConfigurations() { List <string> solutionConfigurationNames = new List <string>(); SolutionConfigurations solutionConfigurations = _hierarchy.GetDTEProject().DTE.Solution.SolutionBuild.SolutionConfigurations; foreach (SolutionConfiguration2 config in solutionConfigurations) { solutionConfigurationNames.Add(config.Name); } return(solutionConfigurationNames); }
public static UnconfiguredProject GetUnconfiguredProject(this IVsHierarchy hierarchy) { IVsBrowseObjectContext context = hierarchy as IVsBrowseObjectContext; if (context == null) { EnvDTE.Project dteProject = hierarchy.GetDTEProject(); if (dteProject != null) { context = dteProject.Object as IVsBrowseObjectContext; } } return(context?.UnconfiguredProject); }
/// <summary> /// Convenient way to get to the UnconfiguredProject from the hierarchy /// </summary> public static UnconfiguredProject GetUnconfiguredProject(this IVsHierarchy hierarchy) { VsAppShell.Current.AssertIsOnMainThread(); IVsBrowseObjectContext context = hierarchy as IVsBrowseObjectContext; if (context == null) { EnvDTE.Project dteProject = hierarchy.GetDTEProject(); if (dteProject != null) { context = dteProject.Object as IVsBrowseObjectContext; } } return(context?.UnconfiguredProject); }
public async Task <IBuildResult> BuildAsync(string target, IDictionary <string, string> globalProperties) { if (globalProperties == null) { globalProperties = new Dictionary <string, string>(); } await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); IVsOutputWindowPane outputWindowPane = null; IVsOutputWindow outputWindow = ServiceProvider.GlobalProvider.GetService(typeof(SVsOutputWindow)) as IVsOutputWindow; if (outputWindow != null) { outputWindow.GetPane(VSConstants.GUID_BuildOutputWindowPane, out outputWindowPane); } var hostObjects = new HashSet <IHostObject>(); ILogger logger = null; if (outputWindowPane != null) { outputWindowPane.Activate(); logger = new PublishLogger(outputWindowPane); } var loggers = new HashSet <ILogger>() { logger }; if (_buildProject == null) { _buildProject = await GetBuildProject(_hier.GetUnconfiguredProject()); } _hier.GetDTEProject().DTE.Solution.SolutionBuild.BuildProject(globalProperties["Configuration"], _hier.GetDTEProject().UniqueName, true); IBuildResult result = await _buildProject?.BuildAsync(new string[] { target }, CancellationToken.None, true, ImmutableDictionary.ToImmutableDictionary(globalProperties), hostObjects.ToImmutableHashSet(), BuildRequestPriority.High, loggers.ToImmutableHashSet()); return(result); }
/// <summary> /// Get export /// </summary> internal static T GetExport <T>(IVsHierarchy hier) { System.IServiceProvider sp = new Microsoft.VisualStudio.Shell.ServiceProvider((OLE.Interop.IServiceProvider)hier.GetDTEProject().DTE); IComponentModel compMode = sp.GetService <IComponentModel, SComponentModel>(); return(compMode.DefaultExportProvider.GetExport <T>().Value); }
/// <summary> /// Get the unconfigured property provider for the project /// </summary> internal virtual UnconfiguredProject GetUnconfiguredProject(IVsHierarchy hier) { var provider = GetExport <IProjectExportProvider>(hier); return(provider.GetExport <UnconfiguredProject>(hier.GetDTEProject().FileName)); }
public static string GetProjectName(this IVsHierarchy hierarchy) { return(hierarchy.GetDTEProject().Name); }