Synthesis icon indicating copy to clipboard operation
Synthesis copied to clipboard

Cannot restrict model generation to only subset of models in Helix like implementation

Open rroman81 opened this issue 7 years ago • 3 comments

Do you want to request a feature or report a bug? This is a bug or possibly a lack of documentation. Also, it's possible that the problem is betweena keyboard and chair (aka me).

What is the current behavior? I have a Sitecore solution based on Helix and a number of multi-site projects. The Foundation.* and Feature.* layer modules and their models are in their corresponding dlls and deployed to target instance via update packages. The Project layer module which represents one subsite (individual site element) has a model-registration correctly. It is managed as a separate solution which also includes Foundation.* and Feature.* module NuGet package dependencies.

My intent was to make sure that synthesis maps all of the templates and models in code for all layers, but only generates models for Project Layer only as the Feature/Foundation models are already synchronized and its source code is not part of the working solution.

Here is the configuration I used to limit the template synchronization: Base configuration (Foundation.Synthesis.config):

<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
    <sitecore>
        <synthesis>
            <providers>
                <typeListProvider type="Synthesis.Configuration.ConfigurationTypeListProvider, Synthesis">
                    <assemblies hint="list:AddAssembly">
                        <foundation>*.Foundation.*</foundation>
	                    <feature>*.Feature.*</feature>
                    </assemblies>
                </typeListProvider>
            </providers>
        </synthesis>
        <settings>			
            <setting name="Synthesis.ModelOutputBasePath" value="$(sourceFolder)\" />
        </settings>
        <pipelines>
            <initialize>
                <!-- Get rid of Synthesis default configuration -->
                <processor type="Synthesis.Pipelines.Initialize.SynthesisConfigRegistrar, Synthesis">
                    <patch:delete />
                </processor>

                <!-- IMPORTANT: Each registrar instance must have a unique hint value for the patch to work correctly. -->
                <processor type="Synthesis.Pipelines.Initialize.SynthesisConfigRegistrar, Synthesis" hint="banner">
                    <assemblies hint="list:AddAssembly">
                        <foundation>*.Foundation.*</foundation>
                        <feature>*.Feature.*</feature>
                    </assemblies>
                </processor>
            </initialize>
        </pipelines>
    </sitecore>
</configuration>

Project Layer patch to modify base configuration (Project.<SiteName>.Webiste.config):

<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
	<sitecore>
		<synthesis>
			<providers>

				<templateInputProvider type="Synthesis.Configuration.ConfigurationTemplateInputProvider, Synthesis">
					<excludedTemplates hint="list:AddTemplateExclusion">
						<foundation>/sitecore/templates/Foundation/*</foundation>
						<feature>/sitecore/templates/Feature/*</feature>
					</excludedTemplates>
				</templateInputProvider>			
				<typeListProvider type="Synthesis.Configuration.ConfigurationTypeListProvider, Synthesis">
					<assemblies hint="list:AddAssembly">
						<foundation></foundation>
						<feature></feature>
                        <project>*.Project.*.Website</project>
					</assemblies>
				</typeListProvider>
				
			</providers>
		</synthesis>
		<pipelines>
			<initialize>
				<processor type="Synthesis.Pipelines.Initialize.SynthesisConfigRegistrar, Synthesis" hint="banner">
					<assemblies hint="list:AddAssembly">
                        <project>*.Project.*.Website</project>
					</assemblies>
				</processor>
			</initialize>
		</pipelines>
	</sitecore>
</configuration>

If the current behavior is a bug, please provide the steps to reproduce. I am seeing that all models are being re-generated when using the configuration provided above where I am attempting to exclude the templates from Feature and Foundation layer modules.

What is the expected behavior? My expectation was to although it sees synchronized modules for all Layers, the generation phase will utilize the excludedTemplatePath element to ignore Foundation/Feature layer modules.

Please mention your Sitecore version and Synthesis version. Sitecore 8.2 Update 3 + Synthesis 8.2.6

rroman81 avatar Dec 04 '17 20:12 rroman81

Hi @rroman81,

I want to make sure I understand the problem correctly. Synthesis is correctly creating the models for the Foundation and Feature layers. Your project layer is in a different solution, and Synthesis is re-creating the models for Foundation and Feature inside the Project layer, alongside the Project layer models. You don't want the Foundation and Feature models inside the Project models because they're redundant and managed in the other solution.

Is that correct?

blipson89 avatar Dec 05 '17 14:12 blipson89

Yep. That's correct.

rroman81 avatar Dec 08 '17 09:12 rroman81

Check /sitecore/admin/showconfig.aspx and review your Synthesis config section. I suspect that the issue may be because your foundation configs are being registered after the website configs, which would cause the website configs to be unaware of the classes generated for the foundation.

kamsar avatar Dec 14 '17 01:12 kamsar