The Problem
If you use Sitecore Content Serialization to serialize your Sitecore items into yml files (and if you use Leprechaun to generate/update item models automatically in our solution), there are chances you may stumble upon the error as in the snapshot below -
The Solution
If you have used Sitecore Content Serialization, then you will know that it makes use of a module.json file in which you specify details about what items to serialize. It usually looks something like this -
{
"namespace": "Feature.Sample",
"items": {
"includes": [
{
"name": "templates",
"path": "/sitecore/templates/Feature/Sample"
},
{
"name": "renderings",
"path": "/sitecore/layout/Renderings/Feature/Sample"
},
{
"name": "buttons",
"database": "core",
"path": "/sitecore/content/Applications/WebEdit/Custom Experience Buttons/Sample"
}
]
},
"leprechaun": {
"configuration": {
"@extends": "Sample.Base",
"@name": "Feature.Sample"
},
}
}
In the above JSON, the namespace and items nodes are from Sitecore and leprechaun node is from Leprechaun which is a universal, open API for code generation from Rainbow serialized or Sitecore serialized Sitecore templates. Leprechaun uses state-of-the-art Roslyn code generation technology instead of T4 templates for speedy generation that doesn't require Visual Studio.
These module.json files are usually specific to each feature project as the items related to a feature are managed in its feature project. The error we have received is due to the fact that there were more than one module.json file which used same name value in leprechaun node of module.json.
How do we find out which module.json reuses the same name?
We performed a notepad++ search for this and what we found is that the other module.json was present within the same project's obj folder. The module.json file's Copy to Output Directory property in Visual Studio shall be set to Do Not Copy but if they are not set so, it causes module.json file to outputed to obj folder of the project. Hence, the problem occurred. Deleting the file from obj folder and updating its property to Do Not Copy fixed this issue for us.
Hope it helps you! Thanks for reading!!
Comments
Post a Comment