收集最實用的網頁特效代碼!wssv3引入了一種名為“解決方案包”的部署機制。這套機制可以支持將解決方案作為一個整體單元來部署。這樣,我們就可以方便的維護,測試和多次的重復使用。我們可以將制作好的sharepoint解決方案包部署到wssv3或moss的服務器環境中,包括單機環境,或獨立web服務器的小型環境甚至企業大型服務器場環境。
一個解決方案包是一個擴展名為.wsp的cab文件。它包括了所有要部署到前端服務器上的文件和一些xml格式的安裝指導文件。sharepoint提供了豐富的基礎架構,可以實現解決方案包在服務器場環境下的簡單部署。
每個解決方案包必須包含一個名為manifest.xml的頭文件。該文件內部定義了一個solution元素。
下面的manifest.xml文件創建了一個用于列表條目級審批的解決方案。
以下為引用的內容: <solution solutionid="44be5f4a-d561-4981-a318-95abc706364a" xmlns="http://schemas.microsoft.com/sharepoint/"> <featuremanifests> <featuremanifest location="itemauditing/feature.xml" /> </featuremanifests> <templatefiles> <templatefile location="layouts/auditlogviewer.aspx"/> <templatefile location="layouts/itemaudit.aspx"/> <templatefile location="layouts/auditlogworkbook.ashx"/> </templatefiles> <assemblies> <assembly deploymenttarget="globalassemblycache" location="itemauditing.dll" /> </assemblies> </solution> |
為解決方案包生成cab文件
正如上面的例子那樣,manifest.xml文件定義了哪些文件是作為該解決方案的一部分,應該被部署到前端web服務器。定義了manifest.xml文件后,我們需要把它與其他所需的文件一起編譯到一個cab文件中。可以使用命令行工具makecab.exe來進行cab文件的制作。如果要用這個工具,我們還要定義一個.ddf文件來告訴makecab.exe哪些文件要包含到輸出的cab文件中。下面給出一個.ddf的例子,名為cab.ddf,用來為上面的條目級審批解決方案生成itemauditing.wsp解決方案包文件。
以下為引用的內容: .option explicit ; generate errors .set cabinetnametemplate=itemauditing.wsp .set diskdirectorytemplate=cdrom ; all cabinets go in single directory .set compressiontype=mszip ; all files compressed in cabinet files .set uniquefiles="on" .set cabinet=on .set diskdirectory1=package solution/manifest.xml manifest.xml template/features/itemauditing/feature.xml itemauditing/feature.xml template/features/itemauditing/elements.xml itemauditing/elements.xml template/layouts/auditlogviewer.aspx layouts/auditlogviewer.aspx template/layouts/itemaudit.aspx layouts/itemaudit.aspx template/layouts/auditlogworkbook.ashx layouts/auditlogworkbook.ashx bin/debug/itemauditing.dll itemauditing.dll 運行makecab.exe |
創建好.ddf文件后,我們就可以運行如下的命令來生成.wsp解決方案包文件。
以下為引用的內容: makecab /f solution/cab.ddf |
解決方案包很適合作為一個企業級或商業用途的部署文件。可以用visual studio項目的方式在開發環境中創建。對于所有需要部署到開發環境以外的場景,都可以用解決方案包的方式來部署。解決方案包還使得系統管理員可以進行腳本化安裝,這個功能對于許多企業級的it組織十分必要。