Viacheslav Eremin | Visual Studio 2010 and .NET Framework 4 Training Kit | Steps:
 
 
 

Demo outline

In this demo, you see how the SharePoint 2010 Tools can be extended in Visual Studio 2010, with a Custom Project Item Template.

This demo and the provided sample code are based on the walkthrough: Defining a SharePoint Project Item with an Item Template and can be found here (http://msdn.microsoft.com/en-us/library/ee256697%28VS.100%29.aspx .)

This Demo requires Visual Studio 2010 SDK, to download it, visit: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=47305cf4-2bea-43c0-91cd-1b853602dcc5&displaylang=en

You can extend the SharePoint project system in Visual Studio 2010 by creating your own project item types. This demo demonstrates the following features:

A Visual Studio Extension (VSIX) package to deploy a project item template and the extension assembly.

A Visual Studio item template for the project item

A Visual Studio Extension that implements features like:

Adding a custom shortcut menu that serves as a starting point for additional tasks

Custom properties that appears in the Properties window

Code that runs when a developer changes certain properties

Debugging and testing the project item

Run Source\Setup\Setup.bat to create the required SharePoint site for this demo.

Steps:

Review the solution projects and inspect the configuration of the Extension and the VSIX Package projects.

On the extension project review the classes and the code required to implement the features described.

On the VSIX Package open the source.extension.vsixmanifest file designer and review its properties and the Content configured for deployment.

Open the ContosoCustomAction.zip file and review the files contained in this compressed folder.

Debug the project item by pressing F5 in Visual Studio

You should set the CustomActionVSIX project as the StartUp project.

Place several breakpoints in the code to follow the execution flow.

Place a breakpoint at the CustomAction.InitializeType to check the extension is being loaded.

An experimental instance of Visual Studio will start and the Extension will be installed.

Create a new SharePoint project and add a new item.

The new Custom Action project item will be available under SharePoint-2010 item types.

Create a new Custom Action and inspect the create element in Solution Explorer

Test the PropertyItemNameChaged event by changing the name of the element in Solution Explorer, the output is logged in the Output Window

Test the ProjectPropertyChanged event by changing a property inside the Properties window, the output is loggedin the Output Window

Test the menu extension by right-clicking on the item recently created and check the View Custom Action Designer context menu appears.

Modify the elements.xml file in the Custom Action element and modify the Title, Description and Url properties.

Deploy and test the custom action in SharePoint by starting a new instance of the project by pressing the F5 button.

In the configured SharePoint site you can use the Site actions menu to check how the deployed Custom Action works.

Close the Experimental instance of Visual Studio.

Browse the Visual Studio Extension Package output folder (by default bin\Debug) and install the extension by double-clicking on the .vsix file. This will install the extension in the %UserProfile%\AppData\Local\Microsoft\VisualStudio\10.0Exp\Extensions\Microsoft\CustomActionVSIX\1.0 folder.

You may need administrator privilege to do this.

Start a new Visual Studio instance and open Tool menu | Options | Environment | Extensions Manager. Check that the �Load per user extensions when running as administrator� option and restart Visual Studio as administrator.

Verify the Custom Action extension is loaded by following the Testing steps again.

Clean up the environment

Retract the SharePoint solution using the SharePoint project�s �Retract� context menu.

Clean up the experimental Visual Studio instance by executing from the Start menu | Microsoft visual Studio 2010 Beta2 SDK | Tools | Reset the Microsoft Visual Studio 2010 Experimental instance.

Start Visual Studio as administrator and use Tools menu | Extensions Manager to uninstall the Custom Action extension.