我在sharepoint中创建了一个自定义的母版页,里面有很多图片(比如200张)。如何打包要设定到网站集的样式库的所有文件?据我所知,唯一的方法是通过一个特性,但这意味着将每个文件(总共200个)作为一个<file></file>元素列出。有没有更简单的方法?属性IncludeFolders=“??-?”在<module></module>中似乎什么也做不了。
如果所有图像文件都位于我的要素文件夹(例如...\template\features\myFeature\images)内的某个文件夹中,是否可以将整个文件夹配置到样式库?
谢谢。
发布于 2009-08-12 21:10:17
此module.xml文件位于名为"Images“的文件夹中。所有图片也都在此文件夹中(使用sharepoint开发工具for visual studio 2008 v1.3)。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();发布于 2010-09-15 22:17:30
下面是一个适用于我的快速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`" />")
}
}
}https://stackoverflow.com/questions/1268126
复制相似问题