Chapter 16. Developing SharePoint Solutions by Using Visual Studio 2010

Configuring Your Development Environment

Overview of Visual Studio 2010 Features

Developing SharePoint Features

Developing SharePoint Solutions

Developing SharePoint Web Parts

Developing SharePoint Site Definitions

Using PowerShell with SharePoint Foundation 2010

Summary

WITH the flexibility of powerful prewritten Web Parts, Web Part pages, browser-based editing, Microsoft SharePoint Designer–based editing, and connectivity to Microsoft Office applications, it’s amazing how much you can do in SharePoint Foundation 2010 without programming.

Inevitably, however, no tool or set of tools can do everything an organization might want to accomplish right out of the box. For those situations in which a custom set of business or functional requirements must be met, that’s the time to think about writing your own code. In a SharePoint environment, writing your own code usually means writing solutions such as Web Parts, custom workflows, and master pages. These items integrate smoothly with the rest of your SharePoint site, taking advantage of its existing appearance, organization, security, and data management. What’s more, these solutions are reusable. You can write them once and use them for as many pages as you would like or even setup your organization’s own codeplex-type site to share the solutions for SharePoint that you and others have developed.

The purpose of this chapter is to introduce you to the development of SharePoint artifacts and solution development programming. This chapter assumes that you already have some experience with Microsoft .NET programming and with web-based programming in general. Once you learn the added skill set of developing solutions for SharePoint, you will become a valuable asset to your organization.

Configuring Your Development Environment

Configuring a good development environment and using the right tools are essential factors for a pleasant (and more important, productive) SharePoint Foundation 2010 development experience. When you are developing solutions for SharePoint Foundation, it is best to do the development on a computer that is running SharePoint Foundation. This way, you can take full advantage of the development and debugging improvements provided by Microsoft Visual Studio 2010.

The development environment should be installed on a computer that has an x64-capable CPU and at least 4 gigabytes of RAM. The operating system of the computer can be Windows Vista x64 SP1 or SP2, Windows 7 x64, or Windows Server 2008 SP2, or Windows Server 2008 R2. However, it is recommended that the operating system is Windows Server 2008 SP2 or Windows Server 2008 R2. Because the basic requirements for a SharePoint Foundation development environment are not the same as a production environment, it is highly recommended that you do not use the requirements listed in this development section as the requirements when creating in a production environment.

Setting Up Your Development Infrastructure

You can use several different configurations for your SharePoint Foundation development environment. If your organizational budget allows, it is recommended that you use more than one computer—one with SharePoint Foundation, and the other running Microsoft SQL Server 2005 SP2 or Microsoft SQL Server 2008 x64 or SQL Server 2008 R2.

Tip

INSIDE OUT Testing your code

Even though your development environment might only consist of one or two computers. If your code is to be deployed on a SharePoint farm that consists of more than one web front-end, then your company will need to invest in an environment that mimics such a configuration in order to accurately test your code.

Additional computers add extra cost to the development process, so in many cases, using virtual machines is preferred. Use virtual machine tools such as Microsoft Hyper-V, VMware Workstation, or Sun Microsystem’s VirtualBox to virtualize your SharePoint environment.

You should also think seriously about your hard disk choices, especially if you are going to use virtualization, and therefore, you might consider using solid-state technology, but definitely 7,200 rpm disk drives and multiple disks.

Note

For more information about setting up a development environment, go to http://msdn.microsoft.com/en-us/library/ee554869(office.14).aspx.

Post-Installation Configurations

Once the development environment has been set up with one of the recommended versions of Windows Server 2008 and SharePoint Foundation, create a web application to host a Site Collection, based on a site template of your choice. Next, install the development tools.

You will need to install Visual Studio 2010 on the development computer, together with the latest Service Packs. When you first start Visual Studio, you will need to choose your environment settings. This is usually a personal preference. If you are new to Visual Studio, then the General Developer Settings is as good a choice as any.

To use the SharePoint features within Visual Studio, Visual Studio must be run with administrative privileges. You can either choose to right-click the Microsoft Visual Studio 2010 shortcut each time you want to start it and then click Run As Administrator, or you could modify the properties of the shortcut, and then on the Compatibility tab, click Run The Program As An Administrator, as shown in Figure 16-1.

Configure the Visual Studio 2010 shortcut to run as administrator.

Figure 16-1. Configure the Visual Studio 2010 shortcut to run as administrator.

Depending on the solutions that you plan to create, you might need to install Microsoft Office 2010 client applications, including Microsoft SharePoint Designer 2010 and possibly Microsoft Visio Premium 2010. Office 2010 applications are provided in both 32-bit and 64-bit versions. Ensure that you install the version that your company uses, which in most cases is the 32-bit version.

Note

SharePoint Designer is a free product that can be downloaded from http://office.microsoft.com/en-us/sharepoint-designer-help/.

Next, install and configure all browsers with which you need to test your solutions. Set the browser’s home page to the web application you created earlier and configure it to automatically authenticate you when the browser opens by adding your web application to the Local intranet zone. To configure this in Microsoft Internet Explorer (IE), in the Tools menu, click Internet Options. In Internet Explorer 9, open the Tools menu by clicking the cog icon located to the far right of the address box, as shown in Figure 16-2.

Use Internet Options to configure your browser development environment.

Figure 16-2. Use Internet Options to configure your browser development environment.

Depending on your company’s source code strategy, you might need the Team Foundation client installed on your development environment. Otherwise, you will also need to decide on your source code methodology.

Development environments can be large and time consuming to build; companies usually invest time to automate the creation of these environments and virtualize them, thereby enabling their developers to use stable configurations, create restore points prior to testing code changes, and to reliably capture the environment when a problem occurs. Other tools that you should consider for your development environment are listed in the sidebar that follows.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset