Sharepoint 2010 如何刷新无效的SPWebConfigModifications

Sharepoint 2010 如何刷新无效的SPWebConfigModifications,sharepoint-2010,wsp,Sharepoint 2010,Wsp,如何清除无效的SPWebConfigModifications 作为解决方案的一部分,我尝试执行一些无效的修改,但现在我无法摆脱它们,每次运行ApplyWebConfigModifications时,它都会尝试执行无效的修改 如何将它们从系统中冲出?供将来参考(在我的头撞到墙上3天后): 您可以使用此工具: 它将列出农场中安装的每个Web应用程序的所有mod,您可以添加新mod,也可以删除旧mod 该工具将仅列出webapp级别的修改,如果您在服务器场级别安装了mods,则需要运行以下脚本:

如何清除无效的SPWebConfigModifications

作为解决方案的一部分,我尝试执行一些无效的修改,但现在我无法摆脱它们,每次运行ApplyWebConfigModifications时,它都会尝试执行无效的修改

如何将它们从系统中冲出?

供将来参考(在我的头撞到墙上3天后):

您可以使用此工具:

它将列出农场中安装的每个Web应用程序的所有mod,您可以添加新mod,也可以删除旧mod

该工具将仅列出webapp级别的修改,如果您在服务器场级别安装了mods,则需要运行以下脚本:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Navigation;
using Microsoft.SharePoint.Administration;

namespace ModTool
{
    class Program
    {
        static void Main(string[] args)
        {

            SPSite site = new SPSite(args[0]);
            SPWebService service = site.WebApplication.Farm.Services.GetValue<SPWebService>();


            if (args.Length == 1 || string.IsNullOrEmpty(args[1]))
            {
                Console.Out.WriteLine("Listing all Mods and Owners");
                foreach (SPWebConfigModification mod in service.WebConfigModifications)
                {
                    Console.Out.WriteLine("Mod:" + mod.Name + ", Owner:" + mod.Owner);
                }
            }
            else
            {
                Console.Out.WriteLine("Removing all mods owner:" + args[1] + ", reference site:" + args[0]);

                List<SPWebConfigModification> toDelete = new List<SPWebConfigModification>();

                foreach (SPWebConfigModification mod in service.WebConfigModifications)
                {
                    if (mod.Owner == args[1])
                    {
                        toDelete.Add(mod);
                    }
                }

                Console.Out.WriteLine("Found " + toDelete.Count + "Mods");



                foreach (SPWebConfigModification mod in toDelete)
                {
                    service.WebConfigModifications.Remove(mod);
                }
                service.Update();
                SPWebService.ContentService.ApplyWebConfigModifications();
                Console.Out.WriteLine("Done!!");
            }
        }
    }
}
ModTool http://site - List all the mods for the farm, site is just an entry point
ModTool http://site owner -Deletes all the mods for the far wich owner is "owner"