SharePoint Server 2010 軟體開發架構與開發入門 Microsoft SharePoint Server 2010 Ignite! 1/12/2019 SharePoint Server 2010 軟體開發架構與開發入門 曹祖聖 台灣微軟資深講師 jimycao@syset.com http://teacher.syset.com MCP, MCP+I, MCSA, MCSE, MCDBA, MCAD, MCSD, MCTS, MCITP, MCPD, MCT, MVP © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Microsoft SharePoint Server 2010 Ignite! 1/12/2019 大綱 SharePoint 2010 開發環境建置 在 Windows 7 上建置 SharePoint 開發環境 使用 Windows 7 的 VHD 開機功能 使用 Hyper-V 進行開發環境虛擬化與集中化 SharePoint 2010 軟體授權問題 Visual Studio 2010 開發環境 SharePoint 專案結構 SharePoint 專案參考 偵錯與追蹤方式 SharePoint Farm / 沙箱式方案 部署選項 © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
MS Confidential : SharePoint 2010 Developer Workshop (Beta1) SharePoint Server 2010 Microsoft SharePoint Server 2010 (SPS) Microsoft SharePoint Foundation 2010 (MSF 4.0) 開發人員可以在用戶端進行開發 SharePoint 2010 可以安裝在 Windows Vista, 7 上 Browser Clients Microsoft SharePoint Server 2010 MS Word Clients Microsoft SharePoint Foundation 2010 MS Outlook Clients .NET Framework and ASP.NET 3.5 SP1 Internet Information Services 7.0 Windows Server 2008 (x64 only) for Production Environments Windows 7 or Vista (x64 only) for Development Environments only
MS Confidential : SharePoint 2010 Developer Workshop (Beta1) 改善介面與存取功能 更好的開發與設計工具 使用 PowerShell 與 SharePoint 互動 清單與事件的改進 使用 LINQ 存取 SharePoint 新的用戶端物件模型 加強開發工作流程應用程式的支援 可延伸式的 Service Application 架構 透過 SharePoint 存取外部資料 使用新的 Connector Framework 加強搜尋 沙箱式解決方案與部份信任程式碼 Claims-based 安全機制
建置小組開發環境 根據專案與小組的規模,有不同的開發環境建置方式 SharePoint 一定要安裝在開發的機器上 將 SharePoint 直接安裝在 Windows 7 上 使用 Windows 7 VHD 開機 集中化虛擬開發環境 SharePoint 一定要安裝在開發的機器上 多人共同開發時可以導入原始程式碼控管
在 Windows 7 上安裝 SharePoint 正常開機 安裝: SharePoint 2010 Office 2010 Visual Studio 2010 其它.. 存取企業資源: Team System 組建伺服器 其它 … 開發 ! 參考資料: http://msdn.microsoft.com/en-us/library/ee554869(office.14).aspx
SPS2010 安裝在 Windows 7 上 (1/4) 將 SharePoint 2010 光碟解開到 C:\SPS2010 編輯 C:\SPS2010\Files\Setup\config.xml 在 <Configuration> 元素下加入以下子元素 <Setting Id="AllowWindowsClientInstall" Value="True"/> 執行 C:\SPS2010\PrerequisiteInstallerFiles\ FilterPack\FilterPack.msi 下載並安裝 Microsoft Sync Framework http://go.microsoft.com/fwlink/?LinkID=141237 下載並安裝 SQL Server Native Cient http://go.microsoft.com/fwlink/?LinkId=123718
SPS2010 安裝在 Windows 7 上 (2/4) 下載並安裝 Windows Identity Foundation (Windows6.1-KB974405-x64.msu) http://support.microsoft.com/kb/974405 下載並安裝 Chart Control (SPF2010 不需要) http://go.microsoft.com/fwlink/?LinkID=122517 下載並安裝 SQL Server Analysis Services - ADOMD.Net http://download.microsoft.com/download/A/D/0/AD021EF1-9CBC-4D11-AB51-6A65019D4706/SQLSERVER2008_ASADOMD10.msi
SPS2010 安裝在 Windows 7 上 (3/4) 執行命令指令,安裝 IIS 元件: start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-ManagementScriptingTools;IIS-Security;IIS-BasicAuthentication;IIS-WindowsAuthentication;IIS-DigestAuthentication;IIS-RequestFiltering;IIS-Performance;IIS-HttpCompressionStatic;IIS-HttpCompressionDynamic;IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-IIS6ManagementCompatibility;IIS-Metabase;IIS-WMICompatibility;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI;WCF-HTTP-Activation;WCF-NonHTTP-Activation
SPS2010 安裝在 Windows 7 上 (3/4)
SPS2010 安裝在 Windows 7 上 (4/4) 下載並安裝 WCF Hotfix http://go.microsoft.com/fwlink/?LinkID=166231 下載並安裝 ADO.NET Data Services Update for .NET Framework 3.5 SP1 http://go.microsoft.com/fwlink/?LinkId=163524 開始安裝 SPS2010 (獨立伺服器) 在執行 SPS2010 產品設定精靈之前,下載並安裝 SQL Server 2008 KB 970315 x64. http://support.microsoft.com/kb/970315 執行 SPS2010 產品設定精靈
Windows 7 + VHD 開機 實體電腦上安裝 64 位元 Windows 7 正常開機 從現有 VHD 庫中取得 Windows 7 VHD,或者重新安裝 Windows 7 使用 VHD 開機 存取企業資源: Team System 組建伺服器 其它 … * 執行 bcdedit 設定開機選單 * 安裝: SharePoint 2010 Office 2010 Visual Studio 2010 其它.. 開發 !
在 Hyper-V 上用 VHD 開機,並且讓開發人員遠端存取 使用 Hyper-V 來簡化 VHD 的建置與管理 集中化虛擬開發環境 在實體電腦上安裝 Windows Server 2008, 並加裝 Hyper-V 角色 正常開機 複製 VHD 給開發人員用 在 Hyper-V 上用 VHD 開機,並且讓開發人員遠端存取 安裝 SharePoint 2010、Office 2010 、Visual Studio 2010、…,並且將共用的資源複製到共用資料夾上 存取企業資源: Team System 組建伺服器 其它 … 開發 ! 使用 Hyper-V 來簡化 VHD 的建置與管理
SharePoint 開發授權 Microsoft SharePoint Server 2010 試用版 http://technet.microsoft.com/zh-tw/evalcenter/ee388573 參與 Microsoft Partner Program 成為銀級認證並繳交年費約五萬, 將可獲得一定數量的License供開發者使用 https://www.microsoft.com/partner/licensingcalculator/default.aspx 購買 MSDN 約四萬, 可提供一人的授權供開發者開發
專案引用伺服器端函式庫 Microsoft.SharePoint.dll Framework 版本: 3.5 位於: C:\Program Files\Common Files\ Microsoft Shared\Web Server Extensions\14\ISAPI Framework 版本: 3.5 建置平台目標: Any CPU (建議) 或 x64
MS Confidential : SharePoint 2010 Developer Workshop (Beta1) - Farm (SPFarm) - Web Application (SPWebApplication) - Site Collection (SPSite) - Site (SPWeb) - List (SPList) - Item (SPListItem) - Document Library (SPDocumentLibrary) - File (SPFile) - Folder (SPFolder)
MS Confidential : SharePoint 2010 Developer Workshop (Beta1) VS 2010 SharePoint 開發工具 Visual Studio 2010 與 SharePoint 2010 密切整合 新的工具只能針對 SharePoint 2010 SharePoint 伺服器總管 新的專案與項目樣版 新的專案結構
Visual Studio 2010 SharePoint 工具集 MS Confidential : SharePoint 2010 Developer Workshop (Beta1) Visual Studio 2010 SharePoint 工具集 VS2010 + SharePoint 2010 開發人員 SharePoint 伺服器總管 SharePoint 2010 專案與項目樣版 視覺化設計 3rd party 開發人員可以加以延伸 優勢 SharePoint 資料夾與檔案結構抽象化 .wsp 檔案抽象化 減少使用額外工具的需求
MS Confidential : SharePoint 2010 Developer Workshop (Beta1) 一定要用系統管理者身份執行 VS2010 VS2010 需要附加 IIS 的工作程序 w3wp.exe
MS Confidential : SharePoint 2010 Developer Workshop (Beta1) 所有專案都使用標準架構建立 專案屬性 檔案檔案與資料夾 組件部署目標 沙箱式解決方案 網站網址 啓動項目
MS Confidential : SharePoint 2010 Developer Workshop (Beta1) 標準專案節點結構 Properties (所有專案) References (所有專案) Features (SharePoint 2010 專案) Package (SharePoint 2010 專案) SharePoint 專案項目 (額外加入)
Feature 節點與 Feature Designer MS Confidential : SharePoint 2010 Developer Workshop (Beta1) Feature 節點與 Feature Designer Feature 節點裡可以包含一個以上的 features Feature designer 提供設計模式與 XML 文字模式 可以在設計介面上或屬性視窗上設定 feature 屬性 使用快顯功能表在 Feature 節點上加入事件接收器(event receiver) 設計工具允許加入或移除其它 SharePoint 專案項目 (SPI) 可以設定 feature 啓用的相依性
MS Confidential : SharePoint 2010 Developer Workshop (Beta1) Mapped Folders Mapped Folders used to deploy to RootFiles Layouts 資料夾對應到 /_layouts 虛擬目錄 Images 資料夾對應到 /_layouts/images 虛擬目錄 你可以自行對應其它資料夾到網站根目錄下 Layouts 資料夾用來建立應用程式頁面
MS Confidential : SharePoint 2010 Developer Workshop (Beta1) 部署選項 兩種預設的部署組態設定 Default No Activation
MS Confidential : SharePoint 2010 Developer Workshop (Beta1) 建置新版本的 .wsp 檔 停用並移除現有的 feature 解開並刪除舊的.wsp 檔 加入並部署新的 .wsp 檔 在目標網站上啓用 feature 附加至 w3wp.exe 進行偵錯
SharePoint 專案項目 (SPI) 樣版 MS Confidential : SharePoint 2010 Developer Workshop (Beta1) SharePoint 專案項目 (SPI) 樣版
MS Confidential : SharePoint 2010 Developer Workshop (Beta1) SharePoint 專案項目 (SPI) SPI 會和專案一起建置與部署 SPI 是專案檔案的邏輯集合 例如: WebParts + 清單定義 + 工作流程 + … 每一個 SPI 都有一個資料夾 編譯與部署資訊由 SPI 屬性來指定
MS Confidential : SharePoint 2010 Developer Workshop (Beta1) SPI 檔案屬性 專案會追蹤所有 SPI 檔的屬性 Visual Studio 類的屬性代表編譯行為 SharePoint 類的屬性代表部署行為
方案內容改變 Activation dependencies ApplicationResourceFiles Assemblies manifest.xml Activation dependencies ApplicationResourceFiles Assemblies CodeAccessSecurity DwpFiles FeatureManifests Resources RootFiles SiteDefinitionManifests TemplateFiles 新增加 新增功能
Microsoft.POC.Intranet.wsp (WSS Solution Cab) Farm 方案 運作機制 Microsoft.POC.Intranet.wsp (WSS Solution Cab) WSS 組態設定 資料庫 加入 Feature Manifests 刪除 Site definitions Assemblies 部署/升級 取得 Farm 伺服器
Sandboxed 方案 位於網站集合等級 _Catalogs/solutions
Microsoft SharePoint Server 2010 Ignite! 1/12/2019 什麼是沙箱 (sandbox) ? 資源配額與限制執行 存取部份的 物件模型 OM 程式執行權 CAS 執行外部程式限制 開發人員 © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
MS Confidential : SharePoint 2010 Developer Workshop (Beta1) Lecture 13: Sandboxed Solutions - 33 沙箱式 (sandboxed) 解決方案 只允許所有功能的子集合 程式碼在沙箱中執行 由網站集合管理員進行部署 儲存在網站集合 Solution Gallery
沙箱式 (sandboxed) 解決方案 Web-part 部署 資源配額管理 可以部署: Web Parts Event Receivers Feature Activation Receivers 工作流程動作 (Actions) InfoPath 表單 站台與清單樣版 資源配額管理 可限制資源: CPU 使用時間 SQL 指令執行時間 例外數量 自訂程式碼隔離: 在各別行程/伺服器執行 放大規模
MS Confidential : SharePoint 2010 Developer Workshop (Beta1) Lecture 13: Sandboxed Solutions - 35 安裝與執行 沙箱式解決方案 demo
SharePoint 2010 沙箱架構 Host Services (SPUCHostService.exe) FRONT END User Code Server Execution Manager (Inside Application Pool) Host Services (SPUCHostService.exe) IIS (WPW3.EXE) Worker Service (SPUCWorkerProcess.exe) Untrusted Code Subset Object Model Full Object Model
沙箱中程式的限制 Off-box connections, http, web services, etc ADO.net Enterprise features (Search, BCS, etc.) Threading P-Invoke IO Other sites x x x x x x
沙箱式解決方案執行流程 Root SPWeb of SPSite Per-WFE AssemblyCache WebParts.wsp 1 Solution gallery 5 <siteguid>\company. intranet.webpart.wsp\ company.intranet.dll 2 Web Part gallery 6 4 Sandboxed Code Service 3 7
MS Confidential : SharePoint 2010 Developer Workshop (Beta1) Lecture 13: Sandboxed Solutions - 39 物件模型子集合 只能使用 SPSite 以下的類別 不能 使用 SPSecurity 建立 SPSite 只在執行時期進行限制 可以改變參考: C:\Program Files\Common Files \Microsoft Shared \Web Server Extensions\14 \UserCode\assemblies \Microsoft.SharePoint.dll 但是部署之前要換回原本的參考 ! SPSite SPWeb SPList SPListItem
Microsoft SharePoint Server 2010 Ignite! 1/12/2019 Code Access Security AspNetHostingPermission, Level=Minimal SharePointPermission, ObjectModel=true SecurityPermission, Flags=Execution Sandbox User Code My.dll wss_usercode.config Other.dll System DLL Framework Code SharePoint DLL Full Trust SharePoint OM Subset OM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
MS Confidential : SharePoint 2010 Developer Workshop (Beta1) Lecture 13: Sandboxed Solutions - 41 建立沙箱式解決方案 demo
MS Confidential : SharePoint 2010 Developer Workshop (Beta1) 資源監控流程
Microsoft SharePoint Server 2010 Ignite! 1/12/2019 資源監控 Metric Name Description Units Resources Per Point Hard Limit AbnormalProcessTerminationCount Process gets abnormally terminated Count 1 CPUExecutionTime CPU exception time Seconds 3,600 60 CriticalExceptionCount Critical exception fired Number 10 3 InvocationCount Number of times solution has been invoked N/A PercentProcessorTime Note: # of cores not factored in Percentage Units of Overall Processor Consumed 85 100 ProcessCPUCycles CPU Cycles 1E+11 ProcessHandleCount Windows Handles 10,000 1,000 ProcessIOBytes (Hard Limit Only) Bytes written to IO Bytes 1E+08 ProcessThreadCount Number of Threads in Overall Process Threads 200 ProcessVirtualBytes (Hard Limit Only) Memory consumed 1E+09 SharePointDatabaseQueryCount SharePoint DB Queries Invoked 20 SharePointDatabaseQueryTime Amount of time spent waiting for a query to be performed 120 UnhandledExceptionCount Unhanded Exceptions 50 UnresponsiveprocessCount We have to kill the process because it has become unresponsive 2 © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
管理沙箱式解決方案 使用管理中心 PowerShell 可以在 Farm 上直接停用整個沙箱式解決方案 可以部署到指定的伺服器上 Site Settings -> Galleries -> Solutions PowerShell Get-SPSite | foreach-object {$_.Quota.UserCodeMaximumLevel = 300} Get-SPSite | foreach-object {$_.Quota.UserCodeWarningLevel = 100} 可以在 Farm 上直接停用整個沙箱式解決方案 可以部署到指定的伺服器上
MS Confidential : SharePoint 2010 Developer Workshop (Beta1) Lecture 13: Sandboxed Solutions - 45 驗證解決方案 限制解決方案執行 安裝在 Farm 等級的 Featurefeature [GuidAttribute("34805697-1FC4-4b66-AF09-AB48AC0F9D97")] public class PublisherValidator : SPSolutionValidator { [Persisted] List<string> _allowedPublishers; public override void ValidateSolution( SPSolutionValidationProperties properties){ } public override void ValidateAssembly( SPSolutionValidationProperties properties, SPSolutionFile assembly){
MS Confidential : SharePoint 2010 Developer Workshop (Beta1) Lecture 13: Sandboxed Solutions - 46 使用管理中心 管理沙箱式解決方案 demo
Microsoft SharePoint Server 2010 Ignite! 1/12/2019 Developer Dashboard 預設是關閉 使用 STSADM 或 Powershell 來改變設定 指令 STSADM STSADM -o setproperty -pn developer-dashboard -pv on STSADM -o setproperty -pn developer-dashboard -pv off STSADM –o setproperty –pn developer-dashboard –pv OnDemand Powershell Set-SPFarm –DeveloperDashboardEnabled Set-SPFarm –DeveloperDashboardEnabled $false © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
MS Confidential : SharePoint 2010 Developer Workshop (Beta1) Developer Dashboard
MS Confidential : Beta1 SharePoint Developer Workshop Developer Dashboard demo 節流設定 $sitecol = get-spsite “http://moss” $sitecol.WebApplication.MaxItemsPerThrottledOperation $sitecol.WebApplication.MaxItemsPerThrottledOperationWarningLevel $sitecol.WebApplication.AllowOMCodeOverrideThrottleSettings $sitecol.WebApplication.UnthrottledPriviledgeOperationWindowEnabled $sitecol.RootWeb.Lists[“Tasks”].IsThrottled 欄位格式設定 新增欄位 “Quantity” = NUMBER 順便看一下欄位唯一性設定 Formula : [Quantity]>=1 輸入錯誤訊息 輸入 -10 和 10 測試
台灣微軟徵才廣告 台灣微軟正式員工 技術支援部門 負責 SharePoint 及 Office 產品 徵才網址: 連絡: Andy Hung https://careers.microsoft.com/JobDetails.aspx?ss&pg=0&so&rw=3&jid=41085&jlang=EN 連絡: Andy Hung Andy.Hung@microsoft.com
1/12/2019 ©2009 Microsoft, Microsoft Dynamics, the Office logo, and Your potential. Our passion. are trademarks of the Microsoft group of companies. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.