Walkthrough: Deploying a Project Task List Definition
This walkthrough shows you how to use Visual Studio 2010 to create, customize, debug, and deploy a SharePoint list definition to track project tasks.
This walkthrough illustrates the following tasks:
Creating a SharePoint list definition project that contains tasks.
Adding the list definition to a SharePoint feature.
Adding an event receiver to the list.
Creating and customizing a SharePoint package to deploy your feature.
Building and deploying your SharePoint solution.
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.
You need the following components to complete this walkthrough:
Supported editions of Microsoft Windows and SharePoint. For more information, see Requirements for Developing SharePoint Solutions.
Visual Studio 2010 Professional or an edition of Visual Studio Application Lifecycle Management (ALM).
Create a SharePoint list definition project and associate the list definition with tasks.
To create a SharePoint list definition project
Open the New Project dialog box, expand the SharePoint node, and then click 2010.
In the Templates pane, select ListDefinition, name the project ProjectTaskList, and then click OK.
The SharePoint Customization Wizard appears.
Type the local SharePoint site that you use for debugging, and then click Next.
For the Display Name of the list, type Project Task List.
In the What is the type of the list definition drop-down menu, select Tasks, and then click Finish.
The list definition, list instance, feature, and package appear in Solution Explorer.
In the task list definition, you can add an event receiver that automatically sets the due date and description of the task. The following procedure adds a simple event handler to the list instance as an event receiver.
To add an event receiver
Right-click the project node, point to Add, and then click New Item.
In the list of SharePoint 2010 templates, select Event Receiver and name it ProjectTaskListEventReceiver.
The SharePoint Customization Wizard appears.
On the Choose Event Receiver Settings page, select List Item Events as the event receiver type.
Set the Event source item to ProjectTaskList.
In the list of events to handle, check the box next to An item was added and then click Finish.
A new event receiver node is added to the project with a code file that is named ProjectTaskListEventReceiver.
Add code to the ItemAdded method in the ProjectTaskListEventReceiver code file. Each time a new task is added, a default due date and a description is added to the task. The default due date is July 1, 2009.
When you create a SharePoint solution, Visual Studio automatically creates features for the default project items. You can customize the project task list settings for the SharePoint site by using the Feature Designer.
To customize the project task list feature
In Solution Explorer, expand Features.
Double click Feature1.
In the Title field, type Project Task List Feature.
In the Scope drop-down menu, select Web.
In the Properties window, type 22.214.171.124 as the value for the Version property.
When you create a SharePoint project, Visual Studio automatically adds the features that contain the default project items to the package. You can customize the project task list settings for the SharePoint site by using the Package Designer.
To customize the project task list package
In Solution Explorer, double-click Package.
In the Name field, type ProjectTaskListPackage.
Select Reset WebServer.
When you run the project, the SharePoint site opens. However, you must manually navigate to the location of the task list.
To test the project task list
Press F5 to build and deploy your project task list.
The SharePoint site opens.
In the left sidebar, click ProjectTaskList - ListInstance1.
The Project Task List page appears.
In the List Tools tab, click Items.
Click New Item.
In the Title text box, type Task1.
After the site is refreshed, the Task1 task appears with a due date of 7/1/2009.
The detailed view of the task appears, and the description shows "This is a critical task."
After you build and test the project task list, you can deploy it to the local system or a remote system. The local system is the same computer on which you developed the solution, whereas a remote system is a different computer.
To deploy the project task list to the local system
Click Deploy on the Build menu.
Visual Studio recycles the IIS application pool, retracts any existing versions of the solution, copies the solution package (.wsp) file to SharePoint, and then activates its features. You can now use the solution in SharePoint. For more information about deployment configuration steps, see How to: Edit a SharePoint Deployment Configuration.
To deploy the project task list to a remote system
Click Package on the Build menu.
This creates a .wsp file for the solution in your project’s binary debug folder (…\<Project Name>\<Project Name>\bin\Debug).
Copy the .wsp file to the remote SharePoint system.
Use the PowerShell Add-SPUserSolution command to install the package on the remote SharePoint installation. (For farm solutions, use the Add-SPSolution command.)
For example, Add-SPUserSolution C:\MyProjects\ProjectTaskList\ProjectTaskList\bin\Debug\ProjectTaskList.wsp.
Use the PowerShell Install-SPUserSolution command to deploy the solution. (For farm solutions, use the Install-SPSolution command.)
For example, Install-SPUserSolution –Identity ProjectTaskList.wsp –Site http://NewSiteName.
For more information about remote deployment, see Using Solutions and Adding and Deploying Solutions with PowerShell in SharePoint 2010.
You can learn more about how to customize and deploy SharePoint solutions from the following topics: