Pregunta

I'm doing a CodeFluent Entities project and I use the Template Producer to generate a report that print some statistics about my model.

As I could see, this Producer automatically add two references (CodeFluent.Runtime.dll and CodeFluent.Runtime.Web.dll). This is a great feature, nevertheless in my case, I don't generate any C# classes so the target project don't really need those references.

How can I disable this behavior ?

¿Fue útil?

Solución

The Template producer inherits from the CodeDomProducer (the one that generates the BOM). This allows the template producer to have some useful methods like AddToGeneratedFiles that adds the file to Visual Studio target project, or AddCompilationReferences which adds references to the target project.

The producer also inherits some configuration options like Target Project Layout of type CodeFluent.Model.Design.TargetProjectLayoutOptions

[Flags]
public enum TargetProjectLayoutOptions
{
    None        = 0x0,

    [Description("Update All")]
    Update = UpdateReferences | UpdateItems,

    [Description("Update References")]
    UpdateReferences = 0x1,

    [Description("Update Items")]
    UpdateItems = 0x2,

    [Description("Do Not Remove Existing Items")]
    DontRemove = 0x4,

    Default     = Update,
}

As you can see this allows you to not update project references. So to answer your question, your producer configuration should look like

<cf:producer name="Template" typeName="CodeFluent.Producers.CodeDom.TemplateProducer, CodeFluent.Producers.CodeDom">
    <cf:configuration cfx:targetProjectLayout="UpdateItems" [other options] />
</cf:producer>

Happy templating :)

Otros consejos

I'm not sure you really can remove reference from CodeFluent.Runtime.dll, since it actually contains the Template engine, see http://blog.codefluententities.com/2013/12/26/exploring-the-codefluent-runtime-the-template-engine/ in the main project.

But since the generated code may not reference the CodeFluent.Runtime.dll it is not mandatory in the target project.

I aggree that it could be usefull to remove the CodeFluent.Runtime.Web.dll reference if you do not need it (which actually do not contain very much things, according to http://www.softfluent.com/documentation/).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top