Exercise 3: Refactor the Import Result

  1. In the Solution Explorer, expand the ProjectManagement project and the Properties folder. Right-click the Attributes.cs file and choose Delete in order to remove this file from the project. The code in this file was used by VSeWSS to assist in the packaging process and is no longer needed in Visual Studio 2010.
  2. In the Solution Explorer, expand the ProjecLocatorWebPart , right-click the ProjectLocatorWebPart.cs file and choose Open in order to open this code file. In the editor that opens, locate the ProjectLocatorWebPart class. Remove the Guid attribute that is applied to this class. This attribute was used in VSeWSS to assist in the WSP packaging process.
  3. In the Solution Explorer, expand the Project SPI, right-click the ItemEventReceiver.cs file and choose Open in order to open this code file. Locate the using statements at the top of the file. Remove following using statement:

    using VseWSS;
  4. In this same file, locate the ProjectItemEventReceiver class definition. Remove the Guid attribute and the TargetContentType attribute that are applied to this class. These attributes were used in VSeWSS to assist in the WSP packaging process.
  5. In the Solution Explorer expand the Template, CONTROLTEMPLATES and ProjectManagement folders. Locate the ProjectLocator.ascx file. Drag the ProjectLocator.ascx file into the ProjectLocatorWebPart .
  6. In the Solution Explorer, right-click the Template folder and choose Delete in order to remove this mapped folder from the project. The folder is no longer needed since it is now empty after moving the User Control.
  7. Note that moving the User Control outside of the mapped folder does not limit your capacity to deploy the file into the _controltemplates folder. In the Solution Explorer select ProjectLocator.ascx (inside of the ProjectLocatorWebPart SPI) and in the Properties window (bottom right corner), locate the Deployment Location property. Note that the user control currently will not be deployed in the _controltemplates folder. Expand the Deployment Location property and modify the Path into CONTROLTEMPLATES\ProjectManagement\

  8. Using the Solution Explorer, expand the ProjectManagement project, expand the Project folder and open the Project.xml file. Notice how this element definition defines both site columns and a content type.
  9. Right-click the ProjectManagement project, expand Add and choose New Item. In the dialog that appears choose the Empty Element template that is available in the Visual C#SharePoint2010 group. Name the element ProjectStartDateColumn and choose Add in order to add this item to the project.
  10. Move the Field definition for the Project Start Date site column from the Project.xml file (located inside of the Project SPI location) which contains the content type into the new empty Elements.xml file you created in the previous step.
  11. Perform steps 4 and 5 for the Project End Date column and for the Project Owner column.

    Note:
    Now that you have refactored some of the SharePoint artifacts to follow the new Visual Studio 2010 project layout, you need to ensure that the three new site column SPIs are deployed as part of the site collection feature.

    In Visual Studio 2010, on the View menu, expand Other Windows and choose Packaging Explorer. Notice that the three new SPIs have been added to the site level feature.

  12. In the Solution Explorer, locate the key in the Properties folder. You should see the ProjectManagement.snk file, which was also used in the VSeWSS project.
  13. In the Solution Explorer, right-click the ProjectManagement project and choose Properties in order to show the properties pane for this project. In the properties pane, perform the following tasks.
    1. In the vertical tab list, select Signing.
    2. Ensure that Sign the Assembly is checked.
    3. Also Ensure that the Choose a strong namekey file is set to the ProjectManagement.snk key
    Note:
    This concludes the third exercise. You have now refactored the imported project and ensured that the same strong name key file is used.