protected override void ReloadProject()
        {
            IVsSolution4 solution4 = VsSolution as IVsSolution4;

            VsSolution.GetProjectOfUniqueName(DteProject.UniqueName, out IVsHierarchy hierarchy);
            int hr = 0;

            hierarchy.GetGuidProperty(Constants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ProjectIDGuid, out Guid guid);
            ErrorHandler.ThrowOnFailure(hr);
            solution4.UnloadProject(guid, (uint)_VSProjectUnloadStatus.UNLOADSTATUS_UnloadedByUser);
            solution4.ReloadProject(guid);
        }
        /// <summary>
        /// Returns the project in the solution,
        /// given a unique name.
        /// </summary>
        ///
        /// <param name="project">
        /// Full path to the solution project.
        /// </param>
        ///
        /// <returns>
        /// Pointer to the IVsHierarchy interface
        /// of the project referred to by project.
        /// </returns>
        ///
        /// <remarks>
        /// https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.shell.interop.ivshierarchy.
        /// </remarks>
        protected virtual IVsHierarchy GetProjectHierarchyItem(string project)
        {
            const int S_OK = 0;

            int exitCode = VsSolution.GetProjectOfUniqueName(project, out IVsHierarchy hierarchyItem);

            if (exitCode != S_OK)
            {
                AddMessage($"Exit code: { exitCode }", MessageCategory.ER);
            }

            return(hierarchyItem);
        }
示例#3
0
        /// <summary>
        /// Returns the project in the solution,
        /// given a unique name.
        /// </summary>
        ///
        /// <param name="project">
        /// Full path to the solution project.
        /// </param>
        ///
        /// <returns>
        /// Pointer to the IVsHierarchy interface
        /// of the project referred to by project.
        /// </returns>
        ///
        /// <remarks>
        /// https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.shell.interop.ivshierarchy.
        /// </remarks>
        protected virtual IVsHierarchy GetProjectHierarchyItem(string project)
        {
            const int S_OK = 0;

            ThreadHelper.ThrowIfNotOnUIThread();

            int exitCode = VsSolution.GetProjectOfUniqueName(project, out IVsHierarchy hierarchyItem);

            if (exitCode != S_OK)
            {
                AddMessage($"Exit code: { exitCode }", TaskErrorCategory.Error);
            }

            return(hierarchyItem);
        }
 int GetProjectOfUniqueName(string name)
 {
     return(solution.GetProjectOfUniqueName(name, out hierarchy));
 }