locked
How to add a configuration file to 14 hive's Feature/{myfeature} folder using Visual Studio 2010 RRS feed

  • Question

  • I need to have an XML file in my custom feature folder in 14 hive. I was able to generate a WSP using SharePoint project template in visual studio. However, I am not sure how I can add a file to WSP so that it is deployed in my feature folder. I can do this manually but would prefer the automated way.

    I tried adding a SharePoint mapped folder item however, it is copying the xml file to 14 hive's feature root folder but not to my custom feature folder. I also tried changing the deployment type to this mapped folder (under properties) but that is read-only.

    Any pointers?

    Tuesday, November 9, 2010 5:54 PM

Answers

  • This is easy to do with Visual Studio 2010.  Just follow these steps:

    1. Add a new Empty Element to the SharePoint project and make sure it's added to your feature.

    2. Add your XML file to the Empty Element (e.g. select the Empty Element in Solution Explorer, then right-click and select Add->Existing Item...).

    3. Select the XML file in Solution Explorer and open the Properties window.

    4. Ensure that the Deployment Type of the XML file is ElementFile.

    5. Expand the Deployment Location property.

    6. By default, files added to SharePoint project items are deployed to a subfolder of the feature folder (named after the project item); to change that, simply clear the Path property.  The file will now be deployed directly to the feature folder.

    Hope that helps,

    -Phil

    • Marked as answer by diffident Thursday, November 11, 2010 5:35 PM
    Tuesday, November 9, 2010 6:18 PM
    • Marked as answer by diffident Thursday, November 11, 2010 5:35 PM
    Wednesday, November 10, 2010 9:01 AM

All replies

  • This is easy to do with Visual Studio 2010.  Just follow these steps:

    1. Add a new Empty Element to the SharePoint project and make sure it's added to your feature.

    2. Add your XML file to the Empty Element (e.g. select the Empty Element in Solution Explorer, then right-click and select Add->Existing Item...).

    3. Select the XML file in Solution Explorer and open the Properties window.

    4. Ensure that the Deployment Type of the XML file is ElementFile.

    5. Expand the Deployment Location property.

    6. By default, files added to SharePoint project items are deployed to a subfolder of the feature folder (named after the project item); to change that, simply clear the Path property.  The file will now be deployed directly to the feature folder.

    Hope that helps,

    -Phil

    • Marked as answer by diffident Thursday, November 11, 2010 5:35 PM
    Tuesday, November 9, 2010 6:18 PM
  • Thanks for the reply, Phil.

    I have 2 features in my sharepoint project - feature F1 and feature F2. I need to add XML file only to F2. In your first step, you said that I need to make sure that it's added to the feature. How can I make sure of that? When I added the empty element, I do not know to which feature it is associated. Is it associated to both of them?

    Thanks in advance!

    Tuesday, November 9, 2010 8:08 PM
    • Marked as answer by diffident Thursday, November 11, 2010 5:35 PM
    Wednesday, November 10, 2010 9:01 AM