SolvedCostura How to disable Costura.Fody in Debug mode?

I'm using Costura.Fody to embed all dlls into my application assembly.

Is there any way to disable Costura.Fody in Debug build mode? How to make Costura.Fody to work only in Release or custom build configuration?

25 Answers

✔️Accepted Answer

Old question but since Google brings up this as a search result like how it brought me, here's a workaround :

By default Costura.Fody package adds one line into your *.csproj file. Something like :
<Import Project="..\packages\Costura.Fody.1.5.1\build\dotnet\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.1.5.1\build\dotnet\Costura.Fody.targets')" />
Add a condition for configuration name like this :
<Import Project="..\packages\Costura.Fody.1.5.1\build\dotnet\Costura.Fody.targets" Condition="'$(Configuration)' == 'Release' and Exists('..\packages\Costura.Fody.1.5.1\build\dotnet\Costura.Fody.targets')" />

Other Answers:

@SimonCropp FTFY

<DisableFody Condition="'$(Configuration)' == 'Debug'">true</DisableFody>

@masters3d in the first PropertyGroup of your csproj

You can make different FodyWeavers configuration files for debug and release and then use a pre build event to copy the file, e.g.

if $(ConfigurationName) == Debug (
xcopy $(SolutionDir)FodyWeavers_debug.xml $(SolutionDir)FodyWeavers.xml* /Y
) ELSE (
xcopy $(SolutionDir)FodyWeavers_release.xml $(SolutionDir)FodyWeavers.xml* /Y
)

In the FodyWeavers_debug.xml you have to exclude all the assemblies.