Sharepoint Branding - Multiple Provisioning Files

I created a custom homepage on sharepoint that comes with a lot of images (say 200). How to pack all the files that will be provided in the site collection style library? The only way I know this is to use a function, but that means that every single file (all 200 of them) is an element <file></file>. Is there an easier way? Attribute IncludeFolders = "?? - ??" in <module></module>seems to be doing nothing.

If all the image files are in a folder inside my functions folder (for example ... \ template \ features \ myFeature \ images), is there a way to provide the whole folder in the style library?

Thanks.

+3
source share
2 answers

This module.xml file is located in the folder named "Images". All images are also in this folder (using the sharepoint development tools for Visual Studio 2008 v1.3). The wsp package should know all the files to be added, so you need to add each file. (rename .wsp to .cab and open it. Then you can see all the files in the solution)

 <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>

You could create a small C # application to create an xml file for you, something like this:

 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();
+4
source

Here's the Powershell function that works for me:

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`" />")
        }
    }
}
+1
source

Source: https://habr.com/ru/post/1715005/


All Articles