Export (0) Print
Expand All
2 out of 5 rated this helpful - Rate this topic

Walkthrough: Import Items from an Existing SharePoint Site

This walkthrough demonstrates how to import items from an existing SharePoint site into a Visual Studio SharePoint project.

This walkthrough demonstrates the following tasks:

  • Customizing a SharePoint site by adding a custom site column (also known as a field.

  • Exporting a SharePoint site to a .wsp file.

  • Importing the .wsp file into Visual Studio SharePoint by using the .wsp Import project.

  • NoteNote

    Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

You need the following components to complete this walkthrough:

For this example, you will create and customize a SharePoint subsite by adding a new site column to it and by creating another subsite for use later. Later, you will export the first subsite to a .wsp file and then import the custom site column into the second subsite by using the .wsp Import project.

To create and customize a SharePoint site

  1. Open a SharePoint site using a Web browser, such as http://system name/SitePages/Home.aspx.

  2. Create a subsite off of the main SharePoint site by clicking New Site on the Site Actions tab.

  3. In the site Create dialog box, click Blank Site.

  4. In the Title box, enter Site Column Test 1, in the URL name box, enter columntest1, leave the other settings at their default values, and then click Create.

  5. After the site is created, navigate in the browser back to the main site, http://system name/SitePages/Home.aspx.

  6. Again, create a blank subsite off of the main SharePoint site by clicking New Site on the Site Actions tab and selecting Blank Site.

  7. In the Title box, enter Site Column Test 2, in the URL name box, enter columntest2, leave the other settings at their default values, and then click Create.

  8. Navigate back to the first subsite, http://system name/columntest1/SitePages/Home.aspx.

  9. Click Site Settings on the Site Actions tab to display the Site Settings page.

  10. Click the Site columns link in the Galleries section.

  11. Click the Create button at the top of the Site Column Gallery page.

  12. In the Column name box, enter Test Column. Keep the other default values and then click OK.

  13. The column Test Column appears under the Custom Columns heading in the Site Column Gallery.

Next, obtain a SharePoint setup (.wsp) file that contains the SharePoint items and elements that you want to import into your Visual Studio SharePoint project. If you do not already have a .wsp file, then you must create one from an existing SharePoint site. For this example, you will export the default SharePoint site into a .wsp file.

Important noteImportant

If you receive a runtime error performing the following procedure, you have to perform the procedure on a system that has access to the SharePoint site.

To export an existing SharePoint site

  1. In SharePoint, click Site Settings on the Site Actions tab to display the Site Settings page.

  2. Click the Save site as template link in the Site Actions section of the Site Settings page.

  3. In the File name box, enter ExampleSite, and in the Template name box, enter Example Site.

  4. For this example, leave the Include Content check box clear.

    If you select this box, Visual Studio saves all lists and document libraries, and their contents, to the .wsp file. Although this is useful in some circumstances, it is not required for this example.

  5. When the operation completes successfully, click the user solution gallery link to view the .wsp file.

    To view the solutions gallery page later, click Site Actions on the Site Settings tab, click Go to top level site settings in the Site Collection Administration section, and then click the Solutions link in the Galleries section.

  6. In the solutions gallery, click the ExampleSite link to display the File Download dialog box.

  7. Click the Save button in the File Download dialog box and save the file on the system.

Now that you have a .wsp file that contains an item that you want to reuse (the custom site column Test Column), import the .wsp file to access it.

To import a .wsp file

  1. In Visual Studio, display the New Project dialog box by pointing to New on the File menu, and then click New Project.

  2. Expand the SharePoint node under either Visual C# or Visual Basic, and then click 2010.

  3. Click Import SharePoint Solution Package in the Templates pane, leave the name of the project as WspImportProject1, and then click OK.

    The SharePoint Customization Wizard appears.

  4. On the Specify the site and security level for debugging page, enter the URL for the second SharePoint subsite that you created earlier. You will add the new custom Field item, http://system name/columntest2, to that subsite.

  5. In the What is the trust level for this SharePoint solution? section, leave the selection as Deploy as a sandboxed solution.

  6. In the Specify the new project source page, browse to the location on the system where you saved the .wsp file previously and then click Next.

    NoteNote

    Clicking Finish on this page causes all available items in the .wsp file to be imported.

  7. In the Select items to import box, clear all of the items in the list except for Test Column and then click Finish.

    Because there are many items in the list, the easiest way to do this is to press CTRL + A to select all items in the list, press SPACE to clear the selection of all items, and then select the check box next to the Test Column item.

    After the import operation is finished, a new project named WspImportProject1 is created that contains a folder named Fields. In this folder is the custom site column Test Column and its definition file Elements.xml.

Finally, deploy WspImportProject1 to the second SharePoint subsite that you created earlier to view the custom site column.

To deploy the project

  1. In Visual Studio, press F5 to deploy and run the .wsp import project.

  2. Click Site Settings on the Site Actions tab to display the Site Settings page.

  3. Click the Site columns link in the Galleries section.

  4. Scroll down to the Custom Columns section.

    Notice that the custom site column that you imported from the first SharePoint site appears in the list.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.