3

大量の画像 (200 など) を含むカスタム マスター ページを sharepoint に作成しました。サイト コレクションのスタイル ライブラリにプロビジョニングするすべてのファイルをパッケージ化するにはどうすればよいですか? これを行う唯一の方法は機能を使用することですが、それはすべてのファイル (200 個すべて) を<file></file>要素としてリストすることを意味します。もっと簡単な方法はありますか?属性 IncludeFolders="??-??" 何もし<module></module>ないようです。

すべての画像ファイルがフィーチャー フォルダー内のフォルダー (例: ...\template\features\myFeature\images) にある場合、フォルダー全体をスタイル ライブラリにプロビジョニングする方法はありますか?

ありがとう。

4

2 に答える 2

4

このmodule.xmlファイルは、「Images」という名前のフォルダーにあります。すべての写真もこのフォルダーにあります(Visual Studio 2008 v1.3のSharePoint開発ツールを使用)。wspパッケージは、追加するすべてのファイルを認識する必要があるため、各ファイルを追加する必要があります。(.wspの名前を.cabに変更して開きます。これで、ソリューション内のすべてのファイルを確認できます)

 <Elements Id="8f8113ef-75fa-41ef-a0a2-125d74fc29b7" xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="Images" Url="Style Library/Images/myfolder" RootWebOnly="TRUE">
    <File Path="hvi_logo.bmp" Url="hvi_logo.bmp" Type="GhostableInLibrary" />
    <File Path="hvi_logo_small.bmp" Url="hvi_logo_small.bmp" Type="GhostableInLibrary" />
    <File Path="epj-logo.png" Url="epj-logo.png" Type="GhostableInLibrary" />
  </Module>
</Elements>

小さなC#アプリを作成して、次のようなxmlファイルを作成できます。

 var info = new DirectoryInfo(@"c:\pathToImageFolder");
        var files = info.GetFiles();

        TextWriter writer = new StreamWriter(@"c:\pathToImageFolder\module.xml");

        writer.WriteLine("<Elements Id=...");
        foreach (FileInfo file in files)
        {
            writer.WriteLine(string.Format("<File Path='{0}' Url='{0}' Type='GhostableInLibrary' />",file.Name));
        }
        writer.WriteLine("</Elements>");
        writer.Flush();
        writer.Close();
于 2009-08-12T21:10:17.460 に答える
1

これが私のために働く簡単なPowershell関数です:

function Enum-FilesInPath
{
    param([string]$path)

    Get-ChildItem -path $path | foreach-object {
        # if a directory, recurse...
        if ($_.PSIsContainer)
        {
            $recursivePath = [string]::Format("{0}\{1}", $path, $_.Name)
            Enum-FilesInPath $recursivePath
        }
        # else if a file, print out the xml for it
        else
        {
            $finalPath = [string]::Format("{0}\{1}", $path, $_.Name)
            $url = $finalPath.Replace("\", "/") # backslashes for path, forward slashes for urls
            [string]::Format("`t<File Url=`"$url`" Path=`"$fullPath`" Type=`"GhostableInLibrary`" />")
        }
    }
}
于 2010-09-15T14:17:29.847 に答える