internal static string GetProjectTypeGuids(EnvDTE.Project proj) { try { string projectTypeGuids = ""; object service = null; Microsoft.VisualStudio.Shell.Interop.IVsSolution solution = null; Microsoft.VisualStudio.Shell.Interop.IVsHierarchy hierarchy = null; Microsoft.VisualStudio.Shell.Interop.IVsAggregatableProject aggregatableProject = null; int result = 0; service = GetService(proj.DTE, typeof(Microsoft.VisualStudio.Shell.Interop.IVsSolution)); solution = (Microsoft.VisualStudio.Shell.Interop.IVsSolution)service; result = solution.GetProjectOfUniqueName(proj.UniqueName, out hierarchy); if (result == 0) { aggregatableProject = (Microsoft.VisualStudio.Shell.Interop.IVsAggregatableProject)hierarchy; result = aggregatableProject.GetAggregateProjectTypeGuids(out projectTypeGuids); } return(projectTypeGuids); } catch { } return(""); }
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(';')); }
/// <summary> /// This routine returns the document from the RDT. We wrote this routine because /// sometimes 8.3 filenames are used and other times long filenames, so this routine /// tries and, if it fails, canonicalizes the path and tries again. /// </summary> private static int FindAndLockDocument( uint rdtLockType, string fullPathFileName, out VsShell.IVsHierarchy ppHier, out uint pitemid, out IntPtr ppunkDocData, out uint pdwCookie) { var hr = VSConstants.S_FALSE; var rdt = Instance.GetRunningDocumentTable(); ppHier = null; pitemid = 0; ppunkDocData = IntPtr.Zero; pdwCookie = 0; if (rdt != null) { hr = rdt.FindAndLockDocument( rdtLockType, fullPathFileName, out ppHier, out pitemid, out ppunkDocData, out pdwCookie); if (NativeMethods.Failed(hr)) { try { if (Path.IsPathRooted(fullPathFileName) == false) { fullPathFileName = Path.GetFullPath(fullPathFileName); // Canonicalize the file path // Use to get rid of 8.3 filenames, otherwise this'll fail hr = rdt.FindAndLockDocument( rdtLockType, fullPathFileName, out ppHier, out pitemid, out ppunkDocData, out pdwCookie); } } catch (ArgumentException) { } catch (IOException) { } } } return(hr); }
public static void AddMessage( string message, string file, int line, int endLine, int column, int endColumn, Microsoft.VisualStudio.Shell.Interop.IVsHierarchy hierarchy, TaskCategory category = TaskCategory.BuildCompile, TaskPriority priority = TaskPriority.High) { AddTask(message, file, line, endLine, column, endColumn, hierarchy, category, TaskErrorCategory.Message, priority); }
public void ProjectSystemHelper_GetIVsHierarchy() { // Arrange const string projectName = "project"; // Sanity this.testSubject.GetIVsHierarchy(new ProjectMock(projectName)).Should().BeNull("Project not associated with the solution"); ProjectMock project = this.solutionMock.AddOrGetProject(projectName); // Act IVsHierarchy h = this.testSubject.GetIVsHierarchy(project); // Assert h.Should().Be(project, "The test implementation of a ProjectMock is also the one for its IVsHierarcy"); }
public static bool IsSupportedProject(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy project) { if (project == null) { return(false); } // Issue #52: // Excludes a magic and strange SingleFileIntelisens pseudo project in %appdata%\Roaming\Microsoft\VisualStudio\<VS_Version>\SingleFileISense // Seems like that all of these _sfi_***.vcxproj files have the same magic guid // https://blogs.msdn.microsoft.com/vcblog/2015/04/29/single-file-intellisense-and-other-ide-improvements-in-vs2015/ // https://support.sourcegear.com/viewtopic.php?f=5&t=22778 if (project.GetGuid() == new Guid("a7a2a36c-3c53-4ccb-b52e-425623e2dda5")) { return(false); } return(supportedProjects.ContainsKey(project.GetKind())); }
public static bool IsSupportedProject(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy project) { return(project != null && supportedProjects.ContainsKey(project.GetKind())); }
public void SetProjectTypeGuids(Project proj) { if (Helpers2.IsSharePointVSTemplate(proj.DTE, proj)) { //for VS2010 projects the guid do not need to be added return; } bool reloadRequired = false; string templatesDir = Path.Combine(GetTemplateBasePath(), "Items.Cache"); //Helpers.EnsureGaxPackageRegistration("{14822709-B5A1-4724-98CA-57A101D1B079}", GetPackageGuid(), templatesDir, GetPackageCaption()); Helpers.EnsureGaxPackageRegistration("{349C5853-65DF-11DA-9384-00065B846F21}", "{349C5853-65DF-11DA-9384-00065B846F21}", templatesDir, GetPackageCaption()); string projectTypeGuids = ""; //Microsoft.VisualStudio.Shell.Interop.IVsSolution solution = null; Microsoft.VisualStudio.Shell.Interop.IVsHierarchy hierarchy = null; //Microsoft.VisualStudio.Shell.Interop.IVsAggregatableProject aggregatableProject = null; Microsoft.VisualStudio.Shell.Flavor.IVsAggregatableProjectCorrected aggregatableProject = null; int result = 0; //service = GetService(typeof(Microsoft.VisualStudio.Shell.Interop.IVsSolution)); //solution = (Microsoft.VisualStudio.Shell.Interop.IVsSolution)service; IVsSolution solution = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsSolution)) as IVsSolution; if (solution != null) { result = solution.GetProjectOfUniqueName(proj.UniqueName, out hierarchy); if (result == 0) { //aggregatableProject = (Microsoft.VisualStudio.Shell.Interop.IVsAggregatableProject)hierarchy; aggregatableProject = (Microsoft.VisualStudio.Shell.Flavor.IVsAggregatableProjectCorrected)hierarchy; result = aggregatableProject.GetAggregateProjectTypeGuids(out projectTypeGuids); //csharp if (!projectTypeGuids.ToUpper().Contains("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}")) { if (projectTypeGuids != "") { projectTypeGuids += ";"; } projectTypeGuids += "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"; } //wap, warnung: Attach guid before {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} if (!projectTypeGuids.ToUpper().Contains(String.Intern("{349c5851-65df-11da-9384-00065b846f21}").ToUpper())) { reloadRequired = true; if (projectTypeGuids == "") { projectTypeGuids = "{349c5851-65df-11da-9384-00065b846f21}"; } else { projectTypeGuids = "{349c5851-65df-11da-9384-00065b846f21}" + ";" + projectTypeGuids; } } aggregatableProject.SetAggregateProjectTypeGuids(projectTypeGuids); } } else { Helpers.LogMessage(proj.DTE, this, "Could not add ProjectTypeGuids '{349c5851-65df-11da-9384-00065b846f21};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}' to the project"); } if (reloadRequired) { Project selProj = Helpers.GetSelectedProject(proj.DTE); MessageBox.Show("To enable visual editing of ascx controls the type of the project has been changed." + Environment.NewLine + Environment.NewLine + "The project '" + selProj.Name + "' needs to be reloaded manually ('Unload Project').", "Reload project", MessageBoxButtons.OK, MessageBoxIcon.Warning); Helpers.SelectProject(project); Helpers.LogMessage(project.DTE, this, "Updating csproj file"); proj.DTE.ExecuteCommand("File.SaveAll", string.Empty); proj.DTE.ExecuteCommand("Project.UnloadProject", string.Empty); proj.DTE.ExecuteCommand("Project.ReloadProject", string.Empty); //Project selProj = Helpers.GetSelectedProject(proj.DTE); //Helpers.LogMessage(proj.DTE, this, "selected project " + selProj.Name); /* * Window win = proj.DTE.Windows.Item(EnvDTE.Constants.vsWindowKindCommandWindow); * CommandWindow comwin = (CommandWindow)win.Object; * comwin.SendInput("Project.UnloadProject", true); * comwin.SendInput("Project.ReloadProject", true); * * * proj.DTE.ExecuteCommand("File.SaveAll", string.Empty); * proj.DTE.ExecuteCommand("Project.UnloadProject", string.Empty); * proj.DTE.ExecuteCommand("Project.ReloadProject", string.Empty); */ } }
override ModelingDocData CreateDocData(string fileName, VsShell.IVsHierarchy hierarchy, uint itemId) { return(new ORMDesignerDocData(this.ServiceProvider, ORMDesignerEditorFactory.Id)); }