Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Unexpectedly Adding Feature on Load

I have a SharePoint 2010 solution in Visual Studio 2013. Every time I close and reopen Visual Studio, a new feature is added to the solution with one list inside it. The list was removed from another feature that it should be in. It is always the same list. As soon as I open the solution this pops up in the Output window before I do anything...

A new feature Feature2 has been added to the project Solution
C:\Code\Solution\Package\Package.package (0,0): Added Feature2 to Package

What is causing this?

I have tried the following:

  1. Recreated the solution and copied all files over - No change
  2. Checked the package and project manifest. - Everything looks okay.
  3. Loaded the project every different way, including unload and reload command. - No change
  4. Recreated the list it likes to isolate into its own feature - No change
  5. Recreated the feature the list should be in but it keeps moving to this new feature - No change
  6. Added a new list and put it after the problem list in the feature - VS then created 3 new features! It took 3 lists out of my feature and put one in each of its own features. I guess I made it angry.
like image 818
Jonathan Eckman Avatar asked Sep 15 '14 22:09

Jonathan Eckman


2 Answers

If the lists in the same feature have the same Type ID, the tooling will move the lists into a newly created feature, because the Type must be unique within a feature. You can check the documentation on the ListTemplate element for more information.

like image 52
Xiaoying Avatar answered Nov 06 '22 12:11

Xiaoying


It is because features cannot contain list templates that have identical values for Type. This is explained here: https://msdn.microsoft.com/en-us/library/office/ms462947.aspx

Type

Optional Integer.

Provides a unique identifier for the template. This identifier must be unique within the feature, but need not be unique across all feature definitions or site definitions. For a list of the default list template types, see SPListTemplateType.

You will probably find that your Elements.xml file for your list templates contains the same value for Type.

To fix this, you will need to edit the Elements.xml files of the list template and the list instance.

  1. Change the Type of the ListTemplate xml element to a unique integer.
  2. Change the TemplateType of the ListInstance xml element to the same integer

I have started to choose numbers over 1000 to avoid conflicts (Although 1100, 1200, 1220 and 1221 are system types)

like image 43
soniiic Avatar answered Nov 06 '22 10:11

soniiic