Sp-dev-docs: SPFx Library component does not pass the feature definition validation with the SPFx v1.2 setup

Created on 1 Sep 2017  路  10Comments  路  Source: SharePoint/sp-dev-docs

Install App (SPFx solution) on site from the UI with SPFx Library component does not pass the feature definition validation.

Category

  • [ ] Question
  • [ ] Typo
  • [X] Bug
  • [ ] Additional article idea

Expected or Desired Behavior

The SPFx solution is installed on site and does not throw feature definition errors.

Observed Behavior

Feature definition install validation error:

There were problems with the app web definition in the package.
Details: Deployment failed in host web https://xxx.sharepoint.com/sites/xxx for app xxx-xxx-client-side-solution/42b29407-df78-4daa-876b-4a6c98027639. Microsoft.SharePoint.SPException: Feature definition with Id 009bc3e9-6cd1-4506-9b20-3f1879cb0eb8 failed validation, file '/009bc3e9-6cd1-4506-9b20-3f1879cb0eb8/Library_009bc3e9-6cd1-4506-9b20-3f1879cb0eb8.xml', line 1, character 849: The 'Type' attribute is invalid - The value 'Library' is invalid according to its datatype 'http://schemas.microsoft.com/sharepoint/:ClientComponentType' - The Enumeration constraint failed. at Microsoft.SharePoint.Administration.SPSolutionPackage.FeatureXmlValidationCallback.XmlValidationCallBack(Object sender, ValidationEventArgs evtargs) at System.Xml.Schema.XmlSchemaValidator.CheckAttributeValue(Object value, SchemaAttDef attdef) at System.Xml.Schema.XmlSchemaValidator.ValidateAttribute(String lName, String ns, XmlValueGetter attributeValueGetter, String attributeStringValue, XmlSchemaInfo schemaInfo) at System.Xml.XsdValidatingReader.ValidateAttributes() at System.Xml.XsdValidatingReader.ProcessElementEvent() at System.Xml.XsdValidatingReader.Read() at Microsoft.SharePoint.Utilities.SPUtility.XsdValidateXml(XmlTextReader xmlStreamReader, String friendlyName, String pathXsdFile, String tagExpectedRootNode, Int32 desiredPathVersion, ValidationEventHandler xsdValEventHandler) at Microsoft.SharePoint.Utilities.SPUtility.XsdValidateXml(XmlTextReader xmlStreamReader, String friendlyName, String pathXsdFile, String tagExpectedRootNode, ValidationEventHandler xsdValEventHandler) at Microsoft.SharePoint.Packaging.SPTargetWebDeploymentGroup.ValidateAppPartFeatureXsd(PackagePart appPart, Guid featureGuid) at Microsoft.SharePoint.Packaging.SPTargetWebDeploymentGroup.ExtractElementPartToWsp(PackagePart elementPart, TemporaryDirectory wspTempDir, SHA256Managed sha, Guid productId, SPAppInstance appInstance, Guid featureId, String featureWspRelativeDirectory) at Microsoft.SharePoint.Packaging.SPTargetWebDeploymentGroup.ExtractFeaturePartToWsp(SPFeatureAppPart featureAppPart, TemporaryDirectory wspTempDir, SHA256Managed sha, Guid productId, SPAppInstance appInstance) at Microsoft.SharePoint.Packaging.SPTargetWebDeploymentGroup.ExtractFeaturePartsToWsp(List`1 featureAppParts, SPWeb web, TemporaryDirectory wspTempDir, SHA256Managed sha, Guid productId) at Microsoft.SharePoint.Packaging.SPTargetWebDeploymentGroup.GenerateAndActivateUserSolutionFromPackage(SPWeb web, SPAppPackage appPackage, Guid productId, String solutionName, SPSolutionLevel solutionLevel) at Microsoft.SharePoint.Packaging.SPTargetWebDeploymentGroup.InstallOrUpgrade(SPSite site, Nullable`1& solutionId, Boolean& swapNeeded)

Steps to Reproduce

  • Create SPFx solution from the latest yeoman generator (v1.2)
  • Upgrade to the latest SPFx npm packages
  • Add library component to the solution with the following manifest schema:
{
  "$schema": "../../../node_modules/@microsoft/sp-module-interfaces/lib/manifestSchemas/jsonSchemas/clientSideComponentManifestSchema.json",
  "id": "009bc3e9-6cd1-4506-9b20-3f1879cb0ebb",
  "alias": "AnalyticsLibrary",
  "componentType": "Library",
  "version": "*",
  "manifestVersion": 2
}
  • Package and deploy to SharePoint online app catalog.
  • Try to install the app to a site from the UI

I have checked the SPFx schema definitions

Went there and checked the definitions "$schema": "../../../node_modules/@microsoft/sp-module-interfaces/lib/manifestSchemas/jsonSchemas/clientSideComponentManifestSchema.json". There is no indication that the type has changed from 'Library' to something else.

More details

There is the xml definition packaged with the package-solution

<?xml version="1.0" encoding="utf-8"?><Elements xmlns="http://schemas.microsoft.com/sharepoint/"><ClientSideComponent Name="AnalyticsLibrary" Id="009bc3e9-6cd1-4506-9b20-3f1879cb0ebb" ComponentManifest="{&quot;id&quot;:&quot;009bc3e9-6cd1-4506-9b20-3f1879cb0ebb&quot;,&quot;alias&quot;:&quot;AnalyticsLibrary&quot;,&quot;componentType&quot;:&quot;Library&quot;,&quot;version&quot;:&quot;0.0.1&quot;,&quot;manifestVersion&quot;:2,&quot;loaderConfig&quot;:{&quot;entryModuleId&quot;:&quot;analytics-bundle&quot;,&quot;internalModuleBaseUrls&quot;:[&quot;&lt;!-- PATH TO CDN --&gt;/&quot;],&quot;scriptResources&quot;:{&quot;analytics-bundle&quot;:{&quot;type&quot;:&quot;path&quot;,&quot;path&quot;:&quot;analytics-bundle_1cdd325564f761a36117e0d626999e14.js&quot;}}}}" Type="Library" ReturnIfCustomScriptDisabled="true"></ClientSideComponent></Elements>

Seems that SharePoint does not like Type="Library" added to the feature definition in the packaged SPFx solution.

NPM configs

位 npm -g list --depth=0
C:\Users\xxx\AppData\Roaming\npm
+-- @microsoft/[email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]

solution packages:

位 npm list --depth=0
[email protected] C:\Projects\SharePointIntranet\src\xxx-webparts
+-- @microsoft/[email protected]
+-- @microsoft/[email protected]
+-- @microsoft/[email protected]
+-- @microsoft/[email protected]
+-- @microsoft/[email protected]
+-- @microsoft/[email protected]
+-- @types/[email protected]
+-- @types/[email protected]
+-- @types/[email protected]
+-- @types/[email protected]
+-- @types/[email protected]
+-- @types/[email protected]
+-- @types/[email protected]
+-- @types/[email protected]
+-- @types/[email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]

All 10 comments

ComponentType: Library is not yet supported in SharePoint Online, which is why you're seeing the error.

Thanks a lot @waldekmastykarz! The 'Library' schema is being in the SPFx schemas so long that I forgot to ask if it is supported first.

@VelinGeorgiev I'd love it to be supported too, so the more people report the need for it, the bigger the odds it will be shipped.

Hi guys,
I am facing the same issue when I try to add my app to my site. The deployment in the app catalog is OK, without errors, but when I try to add my app to my site, I have the same error, within the feature definition validation, because of my Lybrary component type in my manifest.

What about now? Do you know if it's supported now?

Libraries are still not supported which is why you're getting this error.

Thank you @waldekmastykarz for your reactivity.
I am currently building a large application, and I cannot copy and paste my differents layers in my web parts components.... It would be very ugly and unmaintainable.
Do you know another "clean" approach to deploy an external library used in several web parts in the same app ?

For now, the only option is to publish it as an npm package. Depending how your package is built, you could try defining it as an external so that it's not bundled but loaded as a separate resource.

Ok, thank you for the advice @waldekmastykarz.
I'll work on this approach, and check the next SPFX releases with attention....

I had the same problem, so I just changed "requireCustomScript" from true to false in the ScriptEditorWebPart.manifest.json file and the error about xml validation is gone after upload the sppkg again in my site collection AppCatalog.
https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/react-script-editor

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

Was this page helpful?
0 / 5 - 0 ratings