2010-03-17 73 views
0

我必须给客户一个.wsp文件包括.STP文件功能来创建.wsp文件

请给我如何在精选内的.stp的例子,包括与其他沿该功能文件来创建一个.wsp文件。

我已经去了很多网站,他们显示的步骤,但我不明白如何处理,因为我有不同的文件,如.dlls文件,自定义事件接收器功能,自定义Web部件和网站模板.stp文件所有这一切我需要包括。我需要一个实例,我可以在其中查看manifest.xml文件的确切元素名称或语法。例如:包含和删除.dll文件我们使用汇编元素和相似的功能FeaturesMainfest元素就像我需要一个其他元素的例子,我可以包装所有的文件来创建一个.wsp包

请帮我在这个 感谢 阿卜杜勒Afroze

回答

0

阿卜杜勒

看一看下面的例子。这将是您的主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> 

而在您的功能recivers类你需要上传模板文件到模板文档库。这是一个非常简单的例子。

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