Hands-On Lab
Automating Silverlight Web Part Deployment
Lab version:1.0.0
Last updated:9/28/2018
Contents
Overview
Exercise 1: Automating Silverlight application and Silverlight Web Part Deployment
Task 1 – Creating a WSP to Deploy the Silverlight Application
Task 2 – Deploying and Testing the Silverlight Application and Web Page Pre-configured with the Silverlight Web Part
Exercise 1 Verification
Exercise 2: Automating Silverlight application and Silverlight Web Part Deployment with the Visual Studio Silverlight SharePoint Web Parts Extension
Task 1 – Installing the Visual Studio 2010 Silverlight SharePoint Web Parts Extension
Task 2 – Creating a WSP to Deploy the Silverlight Application
Task 3 – Deploying and Testing the Silverlight Application and Web Page Pre-configured with the Silverlight Web Part
Exercise 2 Verification
Summary
Overview
Visual Studio 2010 provides the ability to create SharePoint Solution Packages and automate the deployment of Silverlight applications to SharePoint site collections. By using a SharePoint Solution Package you can deploy a Silverlight application and a web page containing a Silverlight Web Part pre-configured to display the Silverlight application. Taking this approach allows you to easily roll out new Silverlight applications to SharePoint sites without the need to create a page, add a Silverlight Web Part to the page, and configure the Silverlight Web Part to display the Silverlight application. This cuts down on the amount of documentation and time needed to deploy Silverlight applications to SharePoint sites. This lab will guide the reader through an exercise which uses the Visual Studio 2010 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.
The Visual Studio 2010 SharePoint Silverlight Web Parts Extension provides two SharePoint Project Items (SPIs) that allow developers to deploy existing or new Silverlight applications in the same fashion as described above. This lab will guide the reader through an exercise that uses the Visual Studio 2010 SharePoint Silverlight Web Parts Extension to deploy an existing Silverlight application to a SharePoint site and deploy it on a web page with the Silverlight Web Part.
Objectives
This lab will demonstrate how you can use Visual Studio to automate the dpeloyment of a Silverlight application to a SharePoint site. To demonstrate this concept the reader will
- Use Visual Studio 2010 to create a SharePoint Solution Package that deploys a Silverlight application.
- Use Visual Studio 2010 tocreate a web page that includes a pre-configured Silverlight Web Part to display the Silverlight application.
- Use Visual Studio 2010 to create a SharePoint Solution Package that deploys the web page with the pre-configured Silverlight Web Part.
System Requirements
You must have the following items to complete this lab:
- 2010 Information Worker Demonstration and Evaluation Virtual Machine
- Microsoft Visual Studio 2010
Setup
You must perform the following steps to prepare your computer for this lab...
- Download the 2010 Information Worker Demonstration and Evaluation Virtual Machine from and create the Hyper-V image.
Exercises
This Hands-On Lab comprises the following exercises:
- Automating Silverlight application and Silverlight Web Part deployment
- Automating Silverlight application and Silverlight Web Part deployment with the Visual Studio Silverlight SharePoint Web Parts Extension
Estimated time to complete this lab: 10minutes.
Starting Materials
This Hands-On Lab includes the following starting materials.
- Visual Studio solutions. The lab provides the following Visual Studio solutions that you can use as starting point for the exercises.
◦<INSTALL>\Labs\AutomatingSilverlightWebPartDeployment\Source\begin\Sample.Silverlight.App.sln: A sample Silverlight application used to demonstrate how the Silverlight Web Part displays Silverlight applications on a SharePoint site.
Exercise 1: Automating Silverlight application and Silverlight Web Part Deployment
In this exercise, you will use Visual Studio 2010 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 – Creating a WSP to Deploy the Silverlight Application
In this task, you will use Visual Studio to create a SharePoint Solution Package that deploys a Silverlight application to a SharePoint 2010 site collection.
- Using Visual Studio 2010, open the Sample.Silverlight.App.sln Visual Studio Solution at the following location <INSTALL\Labs\AutomatingSilverlightWebPartDeployment\Source\Before\Sample.Silverlight.App.
- In Visual Studio 2010, clickFile> Add > New Project to add a new project. (Figure 1)
- In the Installed Templates,selectVisual C# -> SharePoint -> 2010and selectEmpty SharePoint Project.
- UnderName:enter SharePoint.Silverlight.Deployment.
- In theLocation: textbox enter <INSTALL\Labs\AutomatingSilverlightWebPartDeployment\Source\Beforeand clickOK.
Figure1
Create an Empty SharePoint project.
- In the SharePoint Customization Wizard, enter theURL for your on premise instance of SharePoint 2010 (i.e.
- SelectDeploy as a sandboxed solutionand clickFinish.
- Right-click the Sample.Silverlight.Appproject and chooseAdd -> New Item.
- SelectVisual C# -> SharePoint -> 2010 -> Module.
- In the Add New Item dialog, under Name: enter Silverlightand clickAdd.
- Include the Silverlight.CSOM project output in the Silverlight.Client.CSOM.
- In the Solution Explorer, Right-click the Silverlight module and selectProperties.
Figure 2
TO-DO
- Click on Project Output References row and click theEllipse button to open the Project Output References dialog.
- ClickAdd and select a new project output reference.
- UnderMembers: select the SharePoint.Silverlight.Deployment project.
- Select the Project Namedropdown underSharePoint.Silverlight.Deploymentproperties: in the right hand panel selectSample.Silverlight.App.
- Using theDeployment Typedropdown, selectElementFile.
Figure 3
Project Output References
- Expand theDeployment location row.
- Deletethe value in the Path row.
- ClickOK to exit the dialog.
- In the Solution Explorer, right click the Sample.txt file and select Delete.
- Click OK.
- Double-click the Elements.xml file under the Silverlight module.
- Add the following code to the Module element.
Xml
Url="_catalogs/masterpage/xaps"
- Add the following code to the File element.
Xml
Type="GhostableInLibrary"
- Make sure the XML is exactly as it appears below:
Xml
<?xmlversion="1.0" encoding="utf-8"?>
Elementsxmlns="
<Module Name="Silverlight" Url="_catalogs/masterpage/xaps">
<File Path="Sample.Silverlight.App.xap"
Url="Sample.Silverlight.App.xap"
Type="GhostableInLibrary"/>
</Module>
</Elements
- Save the Elements.xml file.
Add a module to deploy a custom ASPX page that includes a Silverlight Web Part configured to display the new Silverlight application.
- Right-click the SharePoint.Silverlight.DeploymentSharePoint project and chooseAdd-> New Item.
- SelectVisual C# -> SharePoint-> 2010 -> Module.
- Name the module CustomPages.
- ClickAdd.
- In the Solution Explorer, right-click the Sample.txt file and select Delete.
- Click OK.
Add the TimeEntrySearchPage.aspx included in the student files to the module.
- Right-click the CustomPages module.
- Select Add > Existing Item.
- Browse to the <INSTALL\Labs\AutomatingSilverlightWebPartDeployment\Source\Before\SilverlightTestPage.aspx file and select it.
- Click Add.
- Open the Elements.xml file included in the CustomPages module and replace the content with the following Xml:
Xml
<?xmlversion="1.0" encoding="utf-8"?>
Elementsxmlns="
ModuleName="CustomPages">
<FileUrl="SilverlightTestPage.aspx" Path="CustomPages\SilverlightTestPage.aspx" Type="Ghostable" >
<Property Name="Title" Value="Silverlight Test Page" />
<Property Name="Description" Value="Test Page to demonstrate how to deploy a web page with the Silverlight Web Part preconfigured to display a Silverlight application." />
<AllUsersWebPartWebPartOrder="1" WebPartZoneID="Main" ID="SilverlightWebPart">
<![CDATA[ <webParts
<webPartxmlns="
<metaData
<type name="Microsoft.SharePoint.WebPartPages.SilverlightWebPart, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage
</metaData
<data>
<properties>
<property name="HelpUrl" type="string" />
<property name="AllowClose" type="bool">True</property>
<property name="ExportMode" type="exportmode">All</property>
<property name="Hidden" type="bool">False</property>
<property name="AllowEdit" type="bool">True</property>
<property name="Direction" type="direction">NotSet</property>
<property name="TitleIconImageUrl" type="string" />
<property name="AllowConnect" type="bool">True</property>
<property name="HelpMode" type="helpmode">Modal</property>
<property name="CustomProperties" type="string" null="true" />
<property name="AllowHide" type="bool">True</property>
<property name="Description" type="string">A web part to display a Silverlight application.</property>
<property name="CatalogIconImageUrl" type="string" />
<property name="MinRuntimeVersion" type="string" null="true" />
<property name="ApplicationXml" type="string" />
<property name="AllowMinimize" type="bool">True</property>
<property name="AllowZoneChange" type="bool">True</property>
<property name="CustomInitParameters" type="string" null="true" />
<property name="Height" type="unit">250px</property>
<property name="ChromeType" type="chrometype">Default</property>
<property name="Width" type="unit">800px</property>
<property name="Title" type="string">Silverlight Web Part</property>
<property name="ChromeState" type="chromestate">Normal</property>
<property name="TitleUrl" type="string" />
<property name="Url" type="string">~site/_catalogs/masterpage/xaps/Sample.Silverlight.App.xap</property>
<property name="WindowlessMode" type="bool">True</property>
</properties>
</data>
</webPart
</webParts]]>
</AllUsersWebPart
</File
</Module
</Elements
- Save the Elements.xml file.
Task 2–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 SharePoint.Silverlight.Deploymentproject and choose Deploy.
- Once the status bar displays deploy succeeded, open Internet Explorer and navigate to .
- Verify the Silverlight Web Part displays the Silverlight.Sample.App Silverlight application on the SharePoint page.
Figure 4
Silverlight Web Part
Exercise 1 Verification
In order to verify that you have correctly performed all steps of exercise 1, proceed as follows:
Verification 1
In this verification, you will browse to the SharePoint page where you added the Content 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 .
- Verify the Silverlight Web Part displays the Silverlight.Sample.App Silverlight application on the SharePoint page.
Figure 5
Silverlight Web Part
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.
Note: Before beginning this exercise, close all open instances of Visual Studio 2010.
- In the <INSTALL>\Labs\AutomatingSilverlightWebPartDeployment\Source\Beforefolder, 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, clickFile> New Project to create a new project.
- In the Installed Templates,select Visual C# > SharePoint > 2010 and selectEmpty SharePoint Project.
- Under Name:,enter SP.SL.Existing.Deployment.
- In the Location: textbox enter<INSTALL>\Labs\AutomatingSilverlightWebPartDeployment\Source\Before and clickOK.
- In the SharePoint Customization Wizard, enter theURL for your on premise instance of SharePoint 2010 (i.e.
- Select Deploy as a sandboxed solution and clickFinish.
- In the Visual Studio 2010, clickFileAdd> Existing Project to add an existing project.
- Browse to the <INSTALL>\Labs\AutomatingSilverlightWebPartDeployment\Source\Before\Sample.Silverlight.App folderand select the Sample.Silverlight.App.csprojfile.
- Click Open.
- In the Solution Explorer, right-click the SP.SL.Existing.Deploymentproject and select Add > New Item.
- In the Installed Templates,select Visual C# > SharePoint > 2010 and selectSilverlight Web Part.
Figure 8
Add new item
- Click Add.
Note: 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 theEllipse button to open the Project Output References dialog.
- In the Memberslistbox, select Sample.Silverlight.App.
- Click Remove.
- Click Add to create a new project output reference.
- Under Members:, select the SP.SL.Existing.Deploymentproject.
- Select the Project Name dropdown under SP.SL.Existing.Deploymentproperties: 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.Deploymentproject and choose Deploy.
- Once the status bar displays deploy succeeded, open Internet Explorer and navigate to .
- 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 exercise2, 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 .
- Verify the Silverlight Web Part displays the Silverlight.Sample.App Silverlight application on the SharePoint page.
Figure 12
Silverlight Web Part
Summary
In this lab you have seen how use Visual Studio 2010 to automate the deployment of a Silverlight applicaton to a web page in a SharePoint site collection. You have also seen how to use the Visual Studion SharePoint Silverlight Web Parts Extensions to deploy an existing Silverlight application.