Search code examples
c#.netfody

How to disable separate Fody plugin in Release mode?


I'm using MethodDecorator.Fody (for injecting debug stuff) and some other plugins (PropertyChaged etc.).

Is there any way to disable MethodDecorator.Fody in Release build mode but keep the others enabled?


Solution

  • Into your .csproj put this and customize the Weavers section with those you want for specific configuration

    <PropertyGroup>
        <WeaverConfiguration Condition="'$(Configuration)' == 'Debug'">
            <Weavers>
                <PropertyChanged />
                <MethodDecorator />
                <MethodTimer />
            </Weavers>
        </WeaverConfiguration>
    
        <WeaverConfiguration Condition="'$(Configuration)' == 'Release'">
            <Weavers>
                <PropertyChanged />
                <MethodDecorator />
            </Weavers>
        </WeaverConfiguration>
    </PropertyGroup>
    

    Src: https://github.com/Fody/Home/blob/master/pages/configuration.md#merging-configurations:~:text=/%3E%0A%3C/Weavers%3E-,WeaverConfiguration,-entry%20in%20the