包含 .STP 文件作为创建 .WSP 文件的功能

发布于 2024-08-25 16:31:40 字数 354 浏览 4 评论 0原文

我必须给客户一个 .wsp 文件

请给我一个示例,说明如何在功能中包含 .stp 以及如何将该功能与其他文件一起包含以创建 .wsp 文件。

我浏览过很多网站,他们显示了步骤,但我不明白如何处理,因为我有不同的文件,如 .dll 文件、自定义事件接收器功能、自定义 Web 部件和网站模板 .stp 文件,所有这些都是我需要包含的。我需要一个示例,可以在其中查看 manifest.xml 文件的确切元素名称或语法。例如:要包含并删除 .dll 文件,我们使用 assembly 元素,并且与 FeaturesMainfest 元素类似,我需要一个其他元素的示例,我可以在其中包装所有文件以创建 .wsp 包,

请帮助我 谢谢 阿卜杜勒·阿弗罗兹

I have to give the client a .wsp file

Please give me an example of how to include the .stp inside the feature and include that feature along with other files to create a .wsp file.

I have gone thru lots of site where they show the steps but I dont understand how to approach as I have got different files like .dlls files, custom event receivers features, custom web part and site template .stp file all this I need to include. I need one exampkle where I can see the exact elements name or syntax of manifest.xml file. For eg: to include and delpy the .dll files we use assembly element and similary for features FeaturesMainfest element like that I need one example of other elements where I can wrap all the files to create a .wsp package

Please help me on this
Thanks
Abdul Afroze

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦幻的味道 2024-09-01 16:31:40

阿卜杜勒,

看看下面的例子。这将是您的主manifest.xml 文件。

    <?xml version="1.0" encoding="utf-8"?>
<!-- Solution created by WSPBuilder. 10/21/2010 11:22:17 AM  -->
<Solution xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SolutionId="c0096412-9324-4bc5-a411-652d319efe59" xmlns="http://schemas.microsoft.com/sharepoint/">
  <FeatureManifests>
    <FeatureManifest Location="xxxxxxx\feature.xml" />
  </FeatureManifests>
  <Assemblies>
    <Assembly Location="xxxxxxxxxxxx.dll" DeploymentTarget="GlobalAssemblyCache" />
  </Assemblies>
  <TemplateFiles>
    <TemplateFile Location="LAYOUTS\xxxxxxx\xxxxxxx.asmx" />
  </TemplateFiles>
  <Resources>
    <Resource Location="xxxxxxx\ListTemplates\xxxxxxx.stp" />
  </Resources>
</Solution>

在您的功能接收器类中,您需要将模板文件上传到模板文档库。这是一个非常简单的例子。

private void UploadTemplates(SPDocumentLibrary templateGallery, string[] templateFiles)
        {
            try
            {
                if (templateGallery != null)
                {
                    foreach (string str in templateFiles)
                    {

                    FileInfo info = new FileInfo(str);
                    SPQuery query = new SPQuery();
                    query.Query = string.Format("<Where><Eq><FieldRef Name='FileLeafRef'/><Value Type='Text'>{0}</Value></Eq></Where>", info.Name);
                    SPListItemCollection items = templateGallery.GetItems(query);
                    int[] numArray = new int[items.Count];
                    for (int i = 0; i < items.Count; i++)
                    {
                        numArray[i] = items[i].ID;
                    }
                    for (int j = 0; j < numArray.Length; j++)
                    {
                        templateGallery.Items.DeleteItemById(numArray[j]);
                    }
                    byte[] file = File.ReadAllBytes(str);
                    templateGallery.RootFolder.Files.Add(info.Name, file);
                }
            }
            else
            {
                 // templateGallery is null
            }
        }
        catch (Exception exception)
        {
          // handle your errors
        }
    }

Abdul,

Have a look at the following example. This will be your main manifest.xml file.

    <?xml version="1.0" encoding="utf-8"?>
<!-- Solution created by WSPBuilder. 10/21/2010 11:22:17 AM  -->
<Solution xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SolutionId="c0096412-9324-4bc5-a411-652d319efe59" xmlns="http://schemas.microsoft.com/sharepoint/">
  <FeatureManifests>
    <FeatureManifest Location="xxxxxxx\feature.xml" />
  </FeatureManifests>
  <Assemblies>
    <Assembly Location="xxxxxxxxxxxx.dll" DeploymentTarget="GlobalAssemblyCache" />
  </Assemblies>
  <TemplateFiles>
    <TemplateFile Location="LAYOUTS\xxxxxxx\xxxxxxx.asmx" />
  </TemplateFiles>
  <Resources>
    <Resource Location="xxxxxxx\ListTemplates\xxxxxxx.stp" />
  </Resources>
</Solution>

And in your feature recivers class you need to upload the template file to the template document library. Here is a very simple example.

private void UploadTemplates(SPDocumentLibrary templateGallery, string[] templateFiles)
        {
            try
            {
                if (templateGallery != null)
                {
                    foreach (string str in templateFiles)
                    {

                    FileInfo info = new FileInfo(str);
                    SPQuery query = new SPQuery();
                    query.Query = string.Format("<Where><Eq><FieldRef Name='FileLeafRef'/><Value Type='Text'>{0}</Value></Eq></Where>", info.Name);
                    SPListItemCollection items = templateGallery.GetItems(query);
                    int[] numArray = new int[items.Count];
                    for (int i = 0; i < items.Count; i++)
                    {
                        numArray[i] = items[i].ID;
                    }
                    for (int j = 0; j < numArray.Length; j++)
                    {
                        templateGallery.Items.DeleteItemById(numArray[j]);
                    }
                    byte[] file = File.ReadAllBytes(str);
                    templateGallery.RootFolder.Files.Add(info.Name, file);
                }
            }
            else
            {
                 // templateGallery is null
            }
        }
        catch (Exception exception)
        {
          // handle your errors
        }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文