如何刷新无效的SPWebConfigModifications

如何清除无效的SPWebConfigModifications?

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

如何将他们冲出系统?

0
额外
意见: 1

1 答案

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

你可以使用这个工具:

http://ianankers.wordpress。 COM/2011/07/14/Web的配置修饰经理换的SharePoint 2010/

它会列出您场中安装的每个WebApp的所有模块,您可以添加新模块并删除旧模块。

该工具只会在Web应用程序级别列出修改,如果您在服务器场级别安装了模块,则需要运行以下脚本:

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();


            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 toDelete = new List();

                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"
0
额外