Visual Studio Unexpectedly Adding Feature on Load

有些话、适合烂在心里 提交于 2019-12-23 09:18:35

问题


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.

回答1:


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.




回答2:


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)



来源:https://stackoverflow.com/questions/25857722/visual-studio-unexpectedly-adding-feature-on-load

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!