逐步解說:使用項目範本建立自訂動作專案項目 (第 1 部分)
您可以建立自己的專案項目類型,藉此擴充 Visual Studio 2010 中的 SharePoint 專案系統。 在本逐步解說中,您將建立可加入至 SharePoint 專案的專案項目,以便在 SharePoint 網站上建立自訂動作。 自訂動作會將功能表項目加入至 SharePoint 網站的 [網站動作] 功能表。
本逐步解說將示範下列工作:
建立為自訂動作定義新的 SharePoint 專案項目類型的 Visual Studio 擴充功能。 新專案項目類型會實作幾個自訂功能:
捷徑功能表可做為專案項目其他相關工作的起點,例如在 Visual Studio 中顯示自訂動作的設計工具。
開發人員變更專案項目以及包含該專案項目之專案的特定屬性時執行的程式碼。
出現在 [方案總管] 中專案項目旁邊的自訂圖示。
建立專案項目的 Visual Studio 項目範本。
建置 Visual Studio Extension (VSIX) 套件以部署專案項目範本和擴充組件。
偵錯和測試專案項目。
這是獨立的逐步解說。 完成本逐步解說之後,您可以將精靈加入至項目範本來增強專案項目。 如需詳細資訊,請參閱逐步解說:使用項目範本建立自訂動作專案項目 (第 2 部分)。
注意事項 |
---|
您可以從下列位置取得本逐步解說所含之完成的專案、程式碼和其他檔案:https://go.microsoft.com/fwlink/?LinkId=191369 (英文)。 |
必要條件
開發電腦上需要下列元件才能完成此逐步解說:
支援的 Microsoft Windows、SharePoint 和 Visual Studio 版本。 如需詳細資訊,請參閱開發 SharePoint 方案的要求。
Visual Studio 2010 SDK。 這個逐步解說使用 SDK 中的 VSIX 專案範本建立 VSIX 套件,以部署專案項目。 如需詳細資訊,請參閱擴充 Visual Studio 中的 SharePoint 工具。
了解下列概念有助於完成此逐步解說 (但非必要):
SharePoint 中的自訂動作。 如需詳細資訊,請參閱自訂動作 (英文)。
Visual Studio 中的項目範本。 如需詳細資訊,請參閱 Visual Studio 範本簡介。
建立專案
若要完成這個逐步解說,您必須建立三個專案:
VSIX 專案。 這個專案會建立 VSIX 套件,以部署 SharePoint 專案項目。
項目範本專案。 這個專案會建立可用以將 SharePoint 專案項目加入至 SharePoint 專案的項目範本。
類別庫專案。 這個專案會實作 Visual Studio 擴充功能,以定義 SharePoint 專案項目的行為。
從建立這些專案開始進行此逐步解說。
若要建立 VSIX 專案
啟動 Visual Studio。
在 [檔案] 功能表上,指向 [新增],然後按一下 [專案]。
在 [新增專案] 對話方塊頂端的下拉式方塊中,確定已選取 [.NET Framework 4]。
在 [新增專案] 對話方塊中,展開 [Visual C#] 或 [Visual Basic] 節點,然後按一下 [擴充性] 節點。
注意事項 [擴充性] 節點只有在安裝 Visual Studio 2010 SDK 時才可使用。 如需詳細資訊,請參閱上方的<必要條件>一節。
按一下 [VSIX 專案] 範本。
在 [名稱] 方塊中,輸入 CustomActionProjectItem。
按一下 [確定]。
Visual Studio 會將 CustomActionProjectItem 專案加入至 [方案總管]。
若要建立項目範本專案
在 [方案總管] 中,以滑鼠右鍵按一下方案節點,按一下 [加入],再按一下 [新增專案]。
注意事項 在 Visual Basic 專案中,方案節點只有在已選取選項對話方塊、專案和方案、一般中的 [永遠顯示方案] 核取方塊時,才會出現在 [方案總管] 中。
在 [新增專案] 對話方塊頂端的下拉式方塊中,確定已選取 [.NET Framework 4]。
在 [新增專案] 對話方塊中,展開 [Visual C#] 或 [Visual Basic] 節點,然後按一下 [擴充性] 節點。
在專案範本清單中,選取 [C# 項目範本] 或 [Visual Basic 項目範本]。
在 [名稱] 方塊中輸入 ItemTemplate。
按一下 [確定]。
Visual Studio 會將 ItemTemplate 專案加入至方案。
若要建立擴充功能專案
在 [方案總管] 中,以滑鼠右鍵按一下方案節點,按一下 [加入],再按一下 [新增專案]。
在 [新增專案] 對話方塊頂端的下拉式方塊中,確定已選取 [.NET Framework 4]。
在 [新增專案] 對話方塊中展開 [Visual C#] 或 [Visual Basic] 節點,然後按一下 [Windows] 節點。
選取 [類別庫] 專案範本。
在 [名稱] 方塊中,輸入 ProjectItemDefinition。
按一下 [確定]。
Visual Studio 隨即將 [ProjectItemDefinition] 專案加入至方案,然後開啟預設的 Class1 程式碼檔。
從專案刪除 Class1 程式碼檔。
設定擴充功能專案
在您撰寫程式碼定義 SharePoint 專案項目類型之前,必須先將程式碼檔案和組件參考加入至擴充功能專案。
若要設定專案
在 ProjectItemDefinition 專案中加入名稱為 CustomAction 的程式碼檔案。
在 [專案] 功能表上,按一下 [加入參考]。
在 [.NET] 索引標籤上,按住 CTRL,然後按一下下列組件,再按一下 [確定]:
Microsoft.VisualStudio.SharePoint
System.ComponentModel.Composition
System.Windows.Forms
定義新的 SharePoint 專案項目類型
建立實作 ISharePointProjectItemTypeProvider 介面的類別,以定義新專案項目類型的行為。 在您要定義新的專案項目類型時實作此介面。
若要定義新的 SharePoint 專案項目類型
在 ProjectItemDefinition 專案中,開啟 CustomAction 程式碼檔案。
使用下列程式碼取代此檔案中的程式碼。
Imports System Imports System.Diagnostics Imports System.ComponentModel Imports System.ComponentModel.Composition Imports Microsoft.VisualStudio.SharePoint Namespace Contoso.SharePointProjectItems.CustomAction ' Export attribute: Enables Visual Studio to discover and load this extension. ' SharePointProjectItemType attribute: Specifies the ID for this new project item type. This string must ' match the value of the Type attribute of the ProjectItem element in the .spdata file for ' the project item. ' SharePointProjectItemIcon attribute: Specifies the icon to display with this project item in Solution Explorer. ' CustomActionProjectItemTypeProvider class: Defines a new type of project item that can be used to create a custom ' action on a SharePoint site. <Export(GetType(ISharePointProjectItemTypeProvider))> _ <SharePointProjectItemType("Contoso.CustomAction")> _ <SharePointProjectItemIcon("ProjectItemDefinition.CustomAction_SolutionExplorer.ico")> _ Partial Friend Class CustomActionProjectItemTypeProvider Implements ISharePointProjectItemTypeProvider Private WithEvents projectItemTypeDefinition As ISharePointProjectItemTypeDefinition ' Configures the behavior of the project item type. Private Sub InitializeType(ByVal projectItemTypeDefinition As ISharePointProjectItemTypeDefinition) _ Implements ISharePointProjectItemTypeProvider.InitializeType projectItemTypeDefinition.Name = "CustomAction" projectItemTypeDefinition.SupportedDeploymentScopes = _ SupportedDeploymentScopes.Site Or SupportedDeploymentScopes.Web projectItemTypeDefinition.SupportedTrustLevels = SupportedTrustLevels.All Me.projectItemTypeDefinition = projectItemTypeDefinition End Sub Private Const DesignerMenuItemText As String = "View Custom Action Designer" Private Sub ProjectItemMenuItemsRequested(ByVal Sender As Object, _ ByVal e As SharePointProjectItemMenuItemsRequestedEventArgs) _ Handles projectItemTypeDefinition.ProjectItemMenuItemsRequested Dim viewDesignerMenuItem As IMenuItem = e.ViewMenuItems.Add(DesignerMenuItemText) AddHandler viewDesignerMenuItem.Click, AddressOf MenuItemClick End Sub Private Sub MenuItemClick(ByVal Sender As Object, ByVal e As MenuItemEventArgs) Dim projectItem As ISharePointProjectItem = CType(e.Owner, ISharePointProjectItem) Dim message As String = String.Format("You clicked the menu on the {0} item. " & _ "You could perform some related task here, such as displaying a designer " & _ "for the custom action.", projectItem.Name) System.Windows.Forms.MessageBox.Show(message, "Contoso Custom Action") End Sub Private Sub ProjectItemNameChanged(ByVal Sender As Object, ByVal e As NameChangedEventArgs) _ Handles projectItemTypeDefinition.ProjectItemNameChanged Dim projectItem As ISharePointProjectItem = CType(Sender, ISharePointProjectItem) Dim message As String = String.Format("The name of the {0} item changed to: {1}", _ e.OldName, projectItem.Name) projectItem.Project.ProjectService.Logger.WriteLine(message, LogCategory.Message) End Sub End Class End Namespace
using System; using System.Diagnostics; using System.ComponentModel; using System.ComponentModel.Composition; using Microsoft.VisualStudio.SharePoint; namespace Contoso.SharePointProjectItems.CustomAction { // Enables Visual Studio to discover and load this extension. [Export(typeof(ISharePointProjectItemTypeProvider))] // Specifies the ID for this new project item type. This string must match the value of the // Type attribute of the ProjectItem element in the .spdata file for the project item. [SharePointProjectItemType("Contoso.CustomAction")] // Specifies the icon to display with this project item in Solution Explorer. [SharePointProjectItemIcon("ProjectItemDefinition.CustomAction_SolutionExplorer.ico")] // Defines a new type of project item that can be used to create a custom action on a SharePoint site. internal partial class CustomActionProjectItemTypeProvider : ISharePointProjectItemTypeProvider { // Implements IProjectItemTypeProvider.InitializeType. Configures the behavior of the project item type. public void InitializeType(ISharePointProjectItemTypeDefinition projectItemTypeDefinition) { projectItemTypeDefinition.Name = "CustomAction"; projectItemTypeDefinition.SupportedDeploymentScopes = SupportedDeploymentScopes.Site | SupportedDeploymentScopes.Web; projectItemTypeDefinition.SupportedTrustLevels = SupportedTrustLevels.All; projectItemTypeDefinition.ProjectItemNameChanged += ProjectItemNameChanged; projectItemTypeDefinition.ProjectItemMenuItemsRequested += ProjectItemMenuItemsRequested; } private const string designerMenuItemText = "View Custom Action Designer"; private void ProjectItemMenuItemsRequested(object sender, SharePointProjectItemMenuItemsRequestedEventArgs e) { e.ViewMenuItems.Add(designerMenuItemText).Click += MenuItemClick; } private void MenuItemClick(object sender, MenuItemEventArgs e) { ISharePointProjectItem projectItem = (ISharePointProjectItem)e.Owner; string message = String.Format("You clicked the menu on the {0} item. " + "You could perform some related task here, such as displaying a designer " + "for the custom action.", projectItem.Name); System.Windows.Forms.MessageBox.Show(message, "Contoso Custom Action"); } private void ProjectItemNameChanged(object sender, NameChangedEventArgs e) { ISharePointProjectItem projectItem = (ISharePointProjectItem)sender; string message = String.Format("The name of the {0} item changed to: {1}", e.OldName, projectItem.Name); projectItem.Project.ProjectService.Logger.WriteLine(message, LogCategory.Message); } } }
在方案總管中建立專案項目的圖示
當您建立自訂 SharePoint 專案項目時,可以將影像 (圖示或點陣圖) 與專案項目產生關聯。 這個影像會出現在 [方案總管] 中該專案項目的旁邊。
在下列程序中,您會建立專案項目的圖示,並且將圖示嵌入擴充組件。 您之前建立之 CustomActionProjectItemTypeProvider 類別的 SharePointProjectItemIconAttribute 會參考此圖示。
若要建立專案項目的自訂圖示
在 [方案總管] 中,以滑鼠右鍵按一下 [ProjectItemDefinition] 專案。
在捷徑功能表上指向 [加入],再按一下 [新增項目]。
在專案項目清單中,按一下 [圖示檔]。
注意事項 在 Visual Basic 專案中,您必須按一下 [一般] 節點才能看見 [圖示檔] 項目。
輸入 CustomAction_SolutionExplorer.ico 做為新圖示的名稱,然後按一下 [加入]。
新圖示隨即開啟於 [影像編輯器] 中。
編輯 16x16 版的圖示檔,以便能夠辨識其設計,然後儲存圖示檔。
在 [方案總管] 中,按一下 [CustomAction_SolutionExplorer.ico]。
在 [屬性] 視窗中按一下 [建置動作] 旁的下拉式清單,然後按一下 [內嵌資源]。
檢查點
在逐步解說中進行至此處時,專案項目的所有程式碼都會位於專案中。 建置專案,以確定在編譯時未發生任何錯誤。
若要建置您的專案
- 在 [建置] 功能表上,選取 [建置方案]。
建立 Visual Studio 項目範本
若要讓其他開發人員使用您的專案項目,您必須建立專案範本或項目範本。 開發人員會在 Visual Studio 中透過建立新專案或在現有專案中加入項目的方式,使用這些範本建立專案項目的執行個體。 在本逐步解說中,請使用 ItemTemplate 專案來設定您的專案項目。
若要建立項目範本
從 ItemTemplate 專案刪除 Class1 程式碼檔案。
在 ItemTemplate 專案中,開啟 ItemTemplate.vstemplate 檔案。
以下列 XML 取代檔案的內容,然後儲存並關閉檔案。
注意事項 下列 XML 適用於 Visual C# 項目範本。 如果您要建立 Visual Basic 項目範本,請將 ProjectType 項目的值取代為 VisualBasic。
<VSTemplate Version="2.0.0" xmlns="https://schemas.microsoft.com/developer/vstemplate/2005" Type="Item"> <TemplateData> <DefaultName>CustomAction</DefaultName> <Name>Custom Action</Name> <Description>SharePoint Custom Action by Contoso</Description> <ProjectType>CSharp</ProjectType> <SortOrder>1000</SortOrder> <Icon>ItemTemplate.ico</Icon> <ProvideDefaultName>true</ProvideDefaultName> </TemplateData> <TemplateContent> <ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$\Elements.xml">Elements.xml</ProjectItem> <ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$\SharePointProjectItem.spdata">CustomAction.spdata</ProjectItem> </TemplateContent> </VSTemplate>
此檔案會定義項目範本的內容和行為。 如需此檔案內容的詳細資訊,請參閱 Visual Studio 範本結構描述參考。
在 [方案總管] 中,以滑鼠右鍵按一下 [ItemTemplate] 專案,按一下 [加入],然後按一下 [新增項目]。
在 [加入新項目] 對話方塊中選取 [文字檔],於 [名稱] 欄位內輸入 CustomAction.spdata,然後按一下 [加入]。
將下列 XML 加入至 CustomAction.spdata 檔案,然後儲存並關閉檔案。
<?xml version="1.0" encoding="utf-8"?> <ProjectItem Type="Contoso.CustomAction" DefaultFile="Elements.xml" xmlns="https://schemas.microsoft.com/VisualStudio/2010/SharePointTools/SharePointProjectItemModel"> <Files> <ProjectItemFile Source="Elements.xml" Target="$fileinputname$\" Type="ElementManifest" /> </Files> </ProjectItem>
此檔案包含專案項目所包含檔案的相關資訊。 ProjectItem 項目的 Type 屬性必須設為與傳遞至專案項目定義 (您之前在本逐步解說中建立的 CustomActionProjectItemTypeProvider 類別) 上的 SharePointProjectItemTypeAttribute 相同的字串。 如需 .spdata 檔案內容的詳細資訊,請參閱 SharePoint 專案項目結構描述參考。
在 [方案總管] 中,以滑鼠右鍵按一下 [ItemTemplate] 專案,按一下 [加入],然後按一下 [新增項目]。
在 [加入新項目] 對話方塊中選取 [XML 檔案],於 [名稱] 欄位內輸入 Elements.xml,然後按一下 [加入]。
以下列 XML 取代 Elements.xml 檔案的內容,然後儲存並關閉檔案。
<?xml version="1.0" encoding="utf-8" ?> <Elements Id="$guid8$" xmlns="https://schemas.microsoft.com/sharepoint/"> <CustomAction Id="Replace this with a GUID or some other unique string" GroupId="SiteActions" Location="Microsoft.SharePoint.StandardMenu" Sequence="1000" Title="Replace this with your title" Description="Replace this with your description" > <UrlAction Url="~site/Lists/Tasks/AllItems.aspx"/> </CustomAction> </Elements>
此檔案會定義在 SharePoint 網站的 [網站動作] 功能表上建立功能表項目的預設自訂動作。 當使用者按一下功能表項目時,UrlAction 中指定的 URL 就會在 Web 瀏覽器中開啟。 如需可用於定義自訂動作之 XML 項目的詳細資訊,請參閱自訂動作定義 (英文)。
(選擇性) 開啟 ItemTemplate.ico 檔案並加以修改,使其具有您可辨識的設計。 此圖示將在 [加入新項目] 對話方塊中該專案項目旁顯示。
在 [方案總管] 中,以滑鼠右鍵按一下 [ItemTemplate] 專案,然後按一下 [卸載專案]。
再次以滑鼠右鍵按一下 [ItemTemplate] 專案,然後按一下 [編輯 ItemTemplate.csproj] 或 [編輯 ItemTemplate.vbproj]。
在專案檔中尋找下列 VSTemplate 項目。
<VSTemplate Include="ItemTemplate.vstemplate">
以下列 XML 取代這個 VSTemplate 項目。
<VSTemplate Include="ItemTemplate.vstemplate"> <OutputSubPath>SharePoint\SharePoint14</OutputSubPath> </VSTemplate>
OutputSubPath 項目會在您建置專案時用以建立項目範本的路徑中,指定其他資料夾。 這裡指定的資料夾,可確保項目範本只有在客戶於 [加入新項目] 對話方塊中按一下 [SharePoint] 節點下的 [2010] 節點時才能使用。
儲存並關閉檔案。
在 [方案總管] 中,以滑鼠右鍵按一下 [ItemTemplate] 專案,然後按一下 [重新載入專案]。
建立 VSIX 套件以部署專案項目
若要部署擴充功能,請在您的方案中使用 VSIX 專案,以建立 VSIX 套件。 首先,修改 VSIX 專案包含的 source.extension.vsixmanifest 檔案,來設定 VSIX 套件。 接著,建置方案來建立 VSIX 套件。
若要設定和建立 VSIX 套件
在 [方案總管] 中,按兩下 [CustomActionProjectItem] 專案底下的 source.extension.vsixmanifest 檔案。
Visual Studio 會在資訊清單編輯器中開啟檔案。 source.extension.vsixmanifest 檔案是所有 VSIX 套件所需要 extension.vsixmanifest 檔案的基準。 如需這個檔案的詳細資訊,請參閱VSIX Extension Schema Reference。
在 [專案名稱] 方塊中,輸入 Custom Action Project Item。
在 [作者] 方塊中,輸入 Contoso。
在 [說明] 方塊中輸入代表自訂動作的 SharePoint 專案項目。
在編輯器的 [內容] 區段中,按一下 [加入內容] 按鈕。
在 [加入內容] 對話方塊的 [選取內容類型] 清單方塊中,選取 [項目範本]。
注意事項 這個值對應於 extension.vsixmanifest 檔案中的 ItemTemplate 項目。 此項目會識別 VSIX 套件中包含專案項目範本的子資料夾。 如需詳細資訊,請參閱 ItemTemplate Element (VSX Schema)。
按一下 [選取來源] 底下的 [專案] 選項按鈕,並選取其旁邊清單方塊中的 [ItemTemplate]。
按一下 [確定]。
在資訊清單編輯器中,再按一下 [加入內容] 按鈕。
在 [加入內容] 對話方塊的 [選取內容類型] 清單方塊中,選取 [MEF 元件]。
注意事項 這個值對應於 extension.vsixmanifest 檔案中的 MefComponent 項目。 這個項目指定 VSIX 套件中的擴充組件名稱。 如需詳細資訊,請參閱 MEFComponent Element (VSX Schema)。
按一下 [選取來源] 底下的 [專案] 選項按鈕,並選取其旁邊清單方塊中的 [ProjectItemDefinition]。
按一下 [確定]。
在 [建置] 功能表上,按一下 [建置方案]。 確定專案編譯時未發生錯誤。
開啟 CustomActionProjectItem 專案的建置輸出資料夾。 確定此資料夾現已包含 CustomActionProjectItem.vsix 檔。
根據預設,建置輸出資料夾為 .. \bin\Debug 資料夾 (位於包含 CustomActionProjectItem 專案的資料夾下)。
測試專案項目
您現在可以測試專案項目。 首先,在 Visual Studio 的實驗執行個體中開始偵錯 CustomActionProjectItem 方案。 接著,在 Visual Studio 的實驗執行個體中,測試 SharePoint 專案中的 [自訂動作] 專案項目。 最後,建置並執行 SharePoint 專案,確認自訂動作功能正常。
若要開始偵錯方案
以系統管理員權限重新啟動 Visual Studio 並且開啟 [CustomActionProjectItem] 專案。
開啟 CustomAction 程式碼檔,然後將中斷點加入至 InitializeType 方法中的第一行程式碼。
按 F5 鍵啟動偵錯作業。
Visual Studio 會將擴充功能安裝至 %UserProfile%\AppData\Local\Microsoft\VisualStudio\10.0Exp\Extensions\Contoso\Custom Action Project Item\1.0,並啟動 Visual Studio 的實驗執行個體。 您將會在 Visual Studio 的這個執行個體中測試專案項目。
若要在 Visual Studio 中測試專案項目
在 Visual Studio 的實驗執行個體中,指向 [檔案] 功能表上的 [新增],然後按一下 [專案]。
展開 [Visual C#] 或 [Visual Basic] (視項目範本所支援的語言而定),然後展開 [SharePoint] 節點,再按一下 [2010]。
在專案範本清單中,按一下 [空專案]。
在 [名稱] 方塊中,輸入 CustomActionTest。
按一下 [確定]。
在 [SharePoint 自訂精靈] 中,輸入要用於偵錯的網站 URL,然後按一下 [完成]。
在 [方案總管] 中,以滑鼠右鍵按一下專案節點,指向 [加入],然後按一下 [新增項目]。
在 [加入新項目] 對話方塊中,按一下 [SharePoint] 節點底下的 [2010] 節點。
確認 [自訂動作] 項目出現在專案項目的清單中。
按一下 [自訂動作],再按 [加入]。
Visual Studio 會將名為 [CustomAction1] 的新項目加入至專案,並且在編輯器中開啟 Elements.xml 檔。
確認另一個 Visual Studio 執行個體中的程式碼在您之前於 InitializeType 方法中設定的中斷點停止。 按 F5 繼續偵錯專案。
在 Visual Studio 的實驗執行個體中,以滑鼠右鍵按一下 [方案總管] 中的 [CustomAction1] 節點,然後按一下 [檢視自訂動作設計工具]。 確認訊息方塊出現,然後按一下 [確定]。
您可以使用此捷徑功能表為開發人員提供額外的選項或命令,例如顯示自訂動作的設計工具。
在 [檢視] 功能表上,按一下 [輸出]。
[輸出] 視窗隨即開啟。
在 [方案總管] 中,以滑鼠右鍵按一下 [CustomAction1] 項目,然後將名稱變更為 MyCustomAction。
您應該會在 [輸出] 視窗中看見確認訊息。此訊息是您在 CustomActionProjectItemTypeProvider 類別中定義的 ProjectItemNameChanged 事件處理常式所撰寫。 當開發人員修改專案項目時,您可以處理此事件和其他專案項目事件以實作自訂行為。
若要測試 SharePoint 中的自訂動作
在 Visual Studio 的實驗執行個體中,開啟 Elements.xml 檔,這個檔案是 [MyCustomAction] 專案項目的子系。
在 Elements.xml 檔中,進行下列變更:
在 CustomAction 項目中,將 Id 屬性設定為 GUID 或其他唯一字串。 例如:
Id="cd85f6a7-af2e-44ab-885a-0c795b52121a"
在 CustomAction 項目中,將 Title 屬性設定如下:
Title="SharePoint Developer Center"
在 CustomAction 項目中,將 Description 屬性設定如下:
Description="Opens the SharePoint Developer Center Web site."
在 UrlAction 項目中,將 Url 屬性設定如下:
Url="https://msdn.microsoft.com/sharepoint/default.aspx"
儲存 Elements.xml 檔。
請按 F5。 自訂動作將會封裝並部署至專案的 [網站 URL] 屬性指定的 SharePoint 網站。 Web 瀏覽器會開啟此網站的預設頁面。
注意事項 如果顯示 [已停用指令碼偵錯] 對話方塊,請按一下 [是] 繼續進行專案偵錯。
按一下 [網站動作] 功能表。 確認名為 [SharePoint 開發人員中心] 的自訂動作出現在此功能表的底部。
按一下 [SharePoint 開發人員中心] 功能表項目。 確認瀏覽器開啟 https://msdn.microsoft.com/sharepoint/default.aspx 這個網站。
關閉 Web 瀏覽器。
清理開發電腦
在您完成測試專案項目之後,請從 Visual Studio 的實驗執行個體中移除專案項目範本。
若要清理開發電腦
在 Visual Studio 的實驗執行個體中,按一下 [工具] 功能表上的 [擴充管理員]。
[擴充管理員] 對話方塊隨即開啟。
在擴充功能清單中,按一下 [自訂動作專案項目],然後按一下 [解除安裝]。
在所顯示的對話方塊中,按一下 [是],確認您要解除安裝擴充功能。
按一下 [立即重新啟動] 完成解除安裝。
關閉 Visual Studio 的兩個執行個體 (Visual Studio 的實驗執行個體,以及其中有開啟 CustomActionProjectItem 專案的執行個體)。
後續步驟
當您完成本逐步解說之後,您可以將精靈加入至項目範本。 當使用者將 [自訂動作] 專案項目加入至 SharePoint 專案時,精靈會收集自訂動作的相關資訊 (例如其位置,以及加以點選時要巡覽的目標 URL),並將此資訊加入至新專案項目中的 Elements.xml 檔案。 如需詳細資訊,請參閱 逐步解說:使用項目範本建立自訂動作專案項目 (第 2 部分)。