In SharePoint 2007, I always manually compiled my WSP package using the makecab.exe tool. As a result, I always had the option of explicitly naming my Feature folder. In SharePoint 2010, you can create a new Feature folder through Visual Studio. However, although you have given your Feature folder a name, if you look at the FEATURES folder after your Feature has been deployed, you might notice that SharePoint actually gives your Feature folder another name; it appends the name of your Visual Studio project to the beginning of the folder name. Most people have one Solution Package per Visual Studio project, so this usually ends up being the name of the Solution that the Feature was a part of. I can see why Microsoft decided to do this; it’s helpful, if you see a bunch of Feature folders listed in your FEATURES directory, to know which Feature has been deployed with which Solution Package.
I have a naming convention that I use when creating new Visual Studio projects: I name my project the same as the namespace that my project contains. As a result, the DLL name that gets compiled with the project will also have the same name, and then my DLL name corresponds to its actual namesapce. However, this means that the project name can be quite long. (I often use the nomenclature of [ClientName].[Product].[Kindofitem], such as “BeckyBertram.SP2010.Lists”.) The problem is that if I have a Feature folder named “ListDefinitions”, then the folder name that actually gets deployed is “BeckyBertram.SP2010.Lists_ListDefinitions”.
There is an easy way around this. If you navigate to your Visual Studio project folder on your file system, then navigate inside one of your Feature folders, you’ll actually see a file with extension of “.feature”. Open this file up in Notepad. You’ll see an XML node like this:
<?xml version="1.0" encoding="utf-8"?> <feature xmlns:dm0="http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core" dslVersion="220.127.116.11" Id="2a841c06-076b-48ce-ac21-fa252027ce7e" description="Provisions custom list definitions." featureId="2a841c06-076b-48ce-ac21-fa252027ce7e" imageUrl="" solutionId="00000000-0000-0000-0000-000000000000" title="Custom List Definitions" version="" deploymentPath="$SharePoint.Project.FileNameWithoutExtension$_$SharePoint.Feature.FileNameWithoutExtension$" xmlns="http://schemas.microsoft.com/VisualStudio/2008/SharePointTools/FeatureModel"> <projectItems> <projectItemReference itemId="afce3e6c-1fdc-4dad-9353-2a512070f513" /> </projectItems> </feature>
Notice the attribute called “deploymentPath”. Simply remove the first part of that, including the project name token and the underscore. The new deploymentPath should look like this:
Once you do this, your Feature folder name will simply be whatever you named it in Visual Studio. Visual Studio seems to have no problem deploying the Feature folder this way once you’ve made the change.
My thanks to astute reader Jacob Egholm, who pointed out that you can actually modify the deploymentPath value right from the Properties window when you double click on your feature in the Solution Explorer: