Esempio n. 1
0
        /// <summary>
        /// Modifies the loaded project by changing the project's proj file
        /// </summary>
        /// <param name="vsProject">project to be modified</param>
        /// <param name="effector"></param>
        private static void ModifyProject(IVsProject vsProject, Func <string, string> effector)
        {
            var project = GlobalServices.getFSharpProjectNode(vsProject);

            set_ProjectTypeGuids(
                project,
                effector(
                    get_ProjectTypeGuids(project)
                    ));

            // Set dirty flag to true to force project save
            project.SetProjectFileDirty(true);

            // Unload the project - also saves the modifications
            ErrorHandler.ThrowOnFailure(GlobalServices.Solution.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, project, 0));

            // Reload the project
            GlobalServices.DTE.ExecuteCommand("Project.ReloadProject", "");
        }
Esempio n. 2
0
        /// <summary>
        /// Modifies the loaded project by changing the project's proj file
        /// </summary>
        /// <param name="vsProject">project to be modified</param>
        /// <param name="effector"></param>
        private static void ModifyProject(IVsProject vsProject, Action <XmlDocument> effector)
        {
            var project        = GlobalServices.getFSharpProjectNode(vsProject);
            var MSBuildProject = project.BuildProject;

            // method get_XmlDocument on the MSBuild project is internal
            // We will have to use reflection to call it
            var minfo = typeof(Microsoft.Build.BuildEngine.Project)
                        .GetMethod("get_XmlDocument", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

            // apply modifications to XML
            effector((XmlDocument)minfo.Invoke(MSBuildProject, new object[] { }));

            // Set dirty flag to true to force project save
            project.SetProjectFileDirty(true);

            // Unload the project - also saves the modifications
            ErrorHandler.ThrowOnFailure(GlobalServices.solution.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, project, 0));

            // Reload the project
            GlobalServices.dte.ExecuteCommand("Project.ReloadProject", "");
        }
Esempio n. 3
0
        public BuildProjectProxy(IVsProject innerProject)
        {
            projectNode = GlobalServices.getFSharpProjectNode(innerProject);

            var item_list  = new List <IBuildItem>();
            var fixup_list = new List <Tuple <IBuildItem, int, int> >();

            foreach (var item in this)
            {
                item_list.Add(item);
                switch (item.Type)
                {
                case "Compile":
                case "Content":
                case "None":
                    int offset;
                    if (int.TryParse(item.GetMetadata(Constants.moveByTag), out offset))
                    {
                        fixup_list.Insert(0, new Tuple <IBuildItem, int, int>(item, offset, item_list.Count - 1));
                    }
                    break;

                default:
                    break;
                }
            }

            foreach (var item in fixup_list)
            {
                for (int i = 1; i <= item.MoveBy; i++)
                {
                    item.Element.SwapWith(item_list[item.Index + i]);
                }
                item_list.Remove(item.Element);
                item_list.Insert(item.Index + item.MoveBy, item.Element);
            }
        }