Exercise 2: Automating Silverlight application and Silverlight Web Part Deployment with the Visual Studio Silverlight SharePoint Web Parts Extension
In this exercise, you will use Visual Studio 2010 Silverlight SharePoint Web Parts extension to create a SharePoint Solution Package that deploys a Silverlight application and a web page that includes a pre-configured Silverlight Web Part to display the Silverlight application.
Task 1 – Installing the Visual Studio 2010 Silverlight SharePoint Web Parts Extension
In this task, you will install the Visual Studio 2010 Silverlight SharePoint Web Parts Extension.
Before beginning this exercise, close all open instances of Visual Studio 2010.
In the <INSTALL>\Labs\AutomatingSilverlightWebPartDeployment\Source\Before folder, double click the VSIX.SharePoint.Silverlight.vsix file.
Figure 6
Visual Studio Extension Installer
Click Install.
Figure 7
Visual Studio Extension Installer – Installation Completed
- Click Close.
Task 2 – Creating a WSP to Deploy the Silverlight Application
In this task, you will use the Visual Studio SharePoint Silverlight Web Parts Extension to create a SharePoint Solution Package that deploys a Silverlight application to a SharePoint 2010 site collection.
- Open Visual Studio 2010.
- In the Visual Studio 2010, click File>> New >> Project to create a new project.
- In the Installed Templates, select Visual C# >> SharePoint >> 2010 and select Empty SharePoint Project.
- Under Name:, enter SP.SL.Existing.Deployment.
- In the Location: textbox enter <INSTALL>\Labs\AutomatingSilverlightWebPartDeployment\Source\Before and click OK.
- In the SharePoint Customization Wizard, enter the URL for your on premise instance of SharePoint 2010 (i.e. https://intranet.contoso.com).
- Select Deploy as a sandboxed solution and click Finish.
- In the Visual Studio 2010, click File>> Add >> Existing Project to add an existing project.
- Browse to the <INSTALL>\Labs\AutomatingSilverlightWebPartDeployment\Source\Before\Sample.Silverlight.App folder and select the Sample.Silverlight.App.csproj file.
- Click Open.
- In the Solution Explorer, right-click the SP.SL.Existing.Deployment project and select Add >> New Item.
In the Installed Templates, select Visual C# >> SharePoint >> 2010 and select Silverlight Web Part.
Click Add.
The Silverlight Web Part SharePoint Project Item automatically recognizes the Sample.Silverlight.App project and creates modules to deploy a web page with the Silverlight Web Part on it to display the Sample.Silverlight.App Silverlight application. It also creates a feature to package the assets and deploy them to a SharePoint site. Notice all the new elements in the Solution Explorer shown below.
Figure 9
Solution Explorer
The next step is to set the Project Output References for the Site Assets Module that deploys the Silverlight application.
- In the Solution Explorer, right-click the Site Assets Module and select Properties.
- Click on Project Output References row and click the Ellipse button to open the Project Output References dialog.
- In the Members listbox, select Sample.Silverlight.App.
- Click Remove.
- Click Add to create a new project output reference.
- Under Members:, select the SP.SL.Existing.Deployment project.
- Select the Project Name dropdown under SP.SL.Existing.Deployment properties: in the right hand panel select Sample.Silverlight.App.
Using the Deployment Type dropdown, select ElementFile.
Figure 10
Project Output References
Click OK to exit the dialog.
Task 3 – Deploying and Testing the Silverlight Application and Web Page Pre-configured with the Silverlight Web Part
In this task, you will test the deployment of the Silverlight application and web page.
- In the Solution Explorer, right-click the SP.SL.Existing.Deployment project and choose Deploy.
- Once the status bar displays deploy succeeded, open Internet Explorer and navigate to https://intranet.contoso.com/SitePages/Sample.Silverlight.AppWebPartPage.aspx.
Verify the Silverlight Web Part displays the Silverlight.Sample.App Silverlight application on the SharePoint page.
Figure 11
Silverlight Web Part
Exercise 2 Verification
In order to verify that you have correctly performed all steps of exercise 2, proceed as follows:
Verification 1
In this verification, you will browse to the SharePoint page where you added the Silverlight Editor Web Part to validate it displays the Silverlight.Sample.App Silverlight application that is running on the web site hosted by Visual Studio 2010.
- Open Internet Explorer and navigate to https://intranet.contoso.com/SitePages/Sample.Silverlight.AppWebPartPage.aspx.
Verify the Silverlight Web Part displays the Silverlight.Sample.App Silverlight application on the SharePoint page.
Figure 12
Silverlight Web Part