Exercise 3: Refactor the Import Result
- 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.
- 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.
- 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:
- 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.
- In the Solution Explorer expand the Template, CONTROLTEMPLATES and ProjectManagement folders. Locate the ProjectLocator.ascx file. Drag the ProjectLocator.ascx file into the ProjectLocatorWebPart .
- 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.
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\
- 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.
- 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.
- 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.
Perform steps 4 and 5 for the Project End Date column and for the Project Owner column.
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.
- 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.
- 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.
- In the vertical tab list, select Signing.
- Ensure that Sign the Assembly is checked.
- Also Ensure that the Choose a strong namekey file is set to the ProjectManagement.snk key
This concludes the third exercise. You have now refactored the imported project and ensured that the same strong name key file is used.