2008-10-16 28 views
3

我拿了一個wsp文件,並像往常一樣執行了我的stsadm -o addsolution。然後我進入中央行政 - >解決方案管理,它表現得很好。然後我部署了Web部件,至今沒有問題。已部署的Web部件未顯示在「Web部件庫:新的Web部件」中

問題是,當我去把它添加到Web部件庫(Web部件庫:新建Web部件)通常是Web部件在列表中,我選中它旁邊的複選框,然後單擊導入庫但它沒有出現在列表中?我可以在我的manifest.xml中丟失一些東西來造成這種情況嗎?我只是編寫並部署了另一個web部分,這個確切的相同的方式,它很好。另外,我寫了一個虛擬web部件,它除了打印「正常工作」以外,什麼都不做,並且獲得了相同的結果。

任何想法?

回答

6

哇...原來這一切我缺少的是對我的類「公共」的聲明!?!

我覺得自己像個白癡。但是,我也必須手動刪除它才能識別它。感謝大家!

1

我有一段相同的行爲。最後,我們編寫了一個cmd工具,它運行「stsadm - o addsolution」,然後將所有xml文件添加到Web部件庫以用於Web部件。

有源(編輯小位):

string cmd_StsAdm = @"C:\Program files\Common files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe"; 
string url_Site = "http://localhost"; 
string url_Web = "http://localhost"; 
if (string.IsNullOrEmpty(url_Web)) { url_Web = url_Web; } 

Console.WriteLine("Deleting sharepoint solution"); 
string args_DeleteSolution = string.Format("-o deletesolution -name \"{0}\" -override", startInfo.fileNameWsp); 
ShellWait(cmd_StsAdm, args_DeleteSolution); 

string filePathWsp = "**** path to wsp file ****"; 
Console.WriteLine("Adding sharepoint solution"); 
string args_AddSolution = string.Format("-o addsolution -filename \"{0}\"", filePathWsp); 
ShellWait(cmd_StsAdm, args_AddSolution); 

Console.WriteLine("Deploy sharepoint solution"); 
string args_DeploySolution = "-o deploysolution -name \"{0}\" -local -allowGacDeployment -url \"{1}\" -force"; 
args_DeploySolution = string.Format(args_DeploySolution, startInfo.fileNameWsp, url_Web); 
ShellWait(cmd_StsAdm, args_DeploySolution); 

int counter = 0; 
foreach (CWebPartVytvoreniInfo wpRslt in solutionInfo.WebParts) { 
    counter++; 
    string msg = string.Format("Aktivace web part {0} - {1} z {2}", wpRslt.Info.Nazev, counter, solutionInfo.WebParts.Count); 
    Console.WriteLine(msg); 
    string args_ActivateFeature = "-o activatefeature -id {0} -url {1}"; 
    args_ActivateFeature = string.Format(args_ActivateFeature, wpRslt.Info.ID, url_Site); 
    ShellWait(cmd_StsAdm, args_ActivateFeature); 
} 

Console.WriteLine("Connecting to sharepoint site"); 
using (Microsoft.SharePoint.SPSite site = new Microsoft.SharePoint.SPSite(url_Site)) { 
    Microsoft.SharePoint.SPList ctg_WebParts = site.GetCatalog(Microsoft.SharePoint.SPListTemplateType.WebPartCatalog); 

    counter = 0; 
    foreach (WebPartInfo wpInfo in solutionInfo.WebParts) { 
     counter++; 
     string dirPath = System.IO.Path.Combine(wpInfo.DirectoryPath); 
     string fileName = wpRslt.Info.Nazev + ".webpart"; 
     string filePath = System.IO.Path.Combine(dirPath, fileName); 

     string msg = string.Format("Uploading file '{0}' - {1} z {2}", fileName, counter, solutionInfo.WebParts.Count); 
     Console.WriteLine(msg); 
     using (System.IO.FileStream fstrm = OtevritSoubor(filePath)) { 
      ctg_WebParts.RootFolder.Files.Add(fileName, fstrm, true); 
     } 
    } 
} 
2

檢查.webpart文件部署到您的網站的wpcatalog文件夾。根據供應的Web應用程序時指定哪個目錄,你會發現它在類似這樣的一個位置:

C:\的Inetpub \ wwwroot的\ WSS \ VirtualDirectories \ 80 \ wpcatalog

1

我發現,如果我部署了web部件,這是以前博肯我不得不除去溶液後手動刪除它,然後再重新添加解決方案

0

目標.NET框架是我的問題。我針對.NET 3.5,並沒有爲我工作。所以我改爲使用.NET 3.0,而且效果很好。

2

我和我一直在研究的Web部件有同樣的問題,但在我的情況下,我只是忘了添加一個Web部件到「特徵中的項目」框。要做到這一點:

  1. Solution Explorer中展現你的特點的子樹。
  2. 雙擊與.feature結束的項目。
  3. 您應該看到功能的標題,描述和範圍的新選項卡。在他們下面有兩個框之間的按鈕。從左側的框中選擇您的Web部件,然後按下按鈕(標記在圖像上)將其添加到功能中。

注意:如果您知道自己在做什麼,也可以按底部的Manifest按鈕並手動編輯Manifest文件。

Adding Web Part to Feature

這確實可以幫助其他SharePoint首發。

+0

謝謝,在我的情況下,功能文件來自一個已啓動的項目,並且我添加的webparts沒有包含在這些功能中,所以我像你說的那樣添加了它,它像一個魅力一樣工作。 – 2015-02-06 10:20:00