문제

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 ?

도움이 되었습니까?

해결책

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 :)

다른 팁

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/).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top