SharePoint development with
Visual Studio has become the primary developer tool familiar to most
custom developers. Visual Studio 2010 made SharePoint development tools
a first-class citizen inside of Visual Studio, and the improvements
build on this progress. Visual Studio 2012 ships with a number of new
templates and tools that make SharePoint development easier. The
SharePoint and Microsoft Office development experience has been bridged
and provides many enhancements.
In addition to the Visual Studio changes and
enhancements, the SharePoint and Office teams focused improvements on
some of the critical areas of need. The primary areas of focus were on
the common tasks performed such as working with lists, debugging, and
testing. You can see many new Visual Studio Templates as well for
quickly building new apps and Office components. There are new Visual
Designers, which provide the comfortable interaction similar to other
data used in Visual Studio. Office 365 has become a popular tool for
many organizations to leverage SharePoint 2013. To enable
customizations on the Office 365 platform, Visual Studio now also
enables Publishing SharePoint Solutions to the servers remotely,
directly within Visual Studio.
With the introduction of apps both for SharePoint
and Office as a recommended option for building enhancements in
SharePoint, Visual Studio has added support for the four stages of
developing apps. These stages are start, design, develop, and publish.
Visual Studio provides the tools to accomplish both the develop and
publish stages of building your app. All the hosting models for app
development are supported as well as the ability to debug your apps
when they are built. No matter which type of integration or SharePoint
UX extensions you select, the development experience within Visual
Studio remains the same.
SharePoint 2013 focuses more on web development
than ever before. The client-side frameworks, REST-based endpoints, and
standards-based code now enable developers to create powerful
applications without major changes to many components. Visual Studio
improves the experience for developers with added IntelliSense for
JavaScript. This can be one of the most difficult and time-consuming
development tasks because the language does not show errors with a
compilation like compiled code. To assist developers with this issue,
Visual Studio now supports debugging the JavaScript.
NOTE The
SharePoint 2010 templates for Visual Studio will be installed by
default with Visual Studio 2012. These project templates would still
work for nondeprecated features, but you should use the SharePoint 2013
templates for any new development.
Finally, there have been improvements to building
components such as Web Parts Project Item templates. To make it easier
to create Silverlight components, there is now a Silverlight Web Part
template. You can use this template to add your own Silverlight
application or create one with Visual Studio. This might be useful if
you know that Silverlight is supported in an environment such as an
intranet and allows for another way to present data and information.
The Sandboxed Visual Web Part is also a part of Visual Studio templates
provided to developers. The SharePoint Project templates have been
updated and streamlined to allow for a clean development experience.
This process included moving some project templates to the project
items list to allow for fewer items to select from when creating a
Visual Studio project.
Before diving into the project types that Visual
Studio supports for SharePoint, spend some time doing a quick walk
around Visual Studio and the capabilities it provides for SharePoint
regardless of the project type you select. These features include the
templates for SharePoint 2013, the ability to import Web Solutions
Packages (WSPs) in the Visual Studio environment, SharePoint Server
Explorer node integration, exploring the Project Explorer, and finally
the changes to the Package Designer that make it possible to build and
deploy both SharePoint apps and SharePoint WSP packages.
1. Starting a New SharePoint 2013 Project
To start building solutions for
SharePoint 2013 with Visual Studio 2012 you need to install the
Microsoft Office Developer Tools for Visual Studio 2012. This set of
tools installs all the project templates needed for apps, Microsoft
Office, and SharePoint development. The developer tools are delivered
using the Web Platform Installer (WebPI) and fully configure the system
during the installation. The tools install on Visual Studio Ultimate,
Premium, or Professional, which must be installed prior to installing
the tools. The default target platform for the developer tools is
x86-bit platforms, and you must install the required x64-bit assemblies
separately for systems built targeting x64-bit hardware.
The page http://msdn.microsoft.com/en-us/office/apps/fp123627 has a list of apps you can build and what you should download, as well as a link to the WebPI package needed for SharePoint 2013.
After the tools are installed, you can create a SharePoint 2013 project by using the New Project menu, as shown in Figure 1.
Depending on the language of choice, you can select either C# or Visual
Basic, and then select Office/SharePoint to see all the project
templates for the three categories: apps, Office, and SharePoint.
2. Visual Studio Integrated List and Content Type Support
One of the most common tasks associated
with Visual Studio was creating lists and content types. This could be
difficult at times because it required modifying XML files. There have
been major improvements with the new editors that are provided and
project items. To help assist in building out a content type, Visual
Studio provides a project template item to create a custom list schema
for use as a reusable column definition. Visual Studio also provides
the new Content Type Editor that provides a visual interface for the
name, type, and required fields of the XML, which generate the
Elements.xml behind the scenes. This editor capability can be seen in
the enhanced list editing experience. The List Editor provides the
ability to change the list, views, and properties.
3. SharePoint Connections in Server Explorer
The Visual Studio Server Explorer
provides a powerful way to visually represent different components of
your server infrastructure, such as browsing through your data
connections, services, event logs, and performance counters. When
developing against SharePoint, you may want to browse your SharePoint
site to understand what content types, fields, workflows, lists, and
libraries are on your site. With the SharePoint Connections in the
Server Explorer, you can see all this information inside of Visual
Studio with a tree view of the site as well as browse the properties of
these items. The SharePoint Connections in Server Explorer are
read-only and cannot be used to modify the properties. Server Explorer
saves you the time required to view the structure, look at properties,
and open them quickly in a web browser. Figure 2 shows the SharePoint Connections within the Server Explorer.
4. Solution Explorer Integration
As part of the Visual Studio
experience, the SharePoint tools for Visual Studio integrate with the
Solution Explorer so that you can see the files that make up your
solution. By default, when you select your project type, Visual Studio
creates all the projects and files needed for your solutions, such as
the feature XML file, the package XML file, and a key to sign your
features, so you can deploy it. In addition, Visual Studio logically
lays out your solution so that you can quickly add new features or
other projects to it.
5. Mapped Folders
Starting with SharePoint 2010, Visual
Studio introduced the concept of Mapped Folders. Mapped Folders
provides a quick solution to get files into the SharePoint Root or
SharePoint Hive (%Program Files%\Common Files\Microsoft Shared\web server extensions\15).
This was extremely difficult to do prior to the integration with Visual
Studio due to how deep the files are buried in the filesystem. You
could use different techniques, such as creating Windows Explorer
shortcuts, to get to the different folders quickly, but that doesn’t
help you inside of Visual Studio projects, where you want to plan an
image or add an artifact to the Layouts folder.
The Mapped Folders provide a way within the
Visual Studio project to map to a designated SharePoint folder such as
the Layouts folder in the SharePoint root. To add a Mapped Folder, you
simply right-click your project in the Solution Explorer, and under the
Add menu, you see three commands: SharePoint Images Mapped Folder,
SharePoint Layouts Mapped Folder, and SharePoint Mapped Folder. The
last one displays a user interface for you to select the folder you
want to map to. By using these capabilities, you can drag and drop
items into your Mapped Folders, and Visual Studio will deploy your
artifacts to the right location in SharePoint.