How to disable Costura.Fody resources embedding in Debug mode?
Asked Answered
C

3

14

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?

Cambyses answered 8/2, 2016 at 9:51 Comment(0)
A
14

One solution might be to check your .csproj file and add a condition to the Fody-related lines. Something like this:

<Content Include="FodyWeavers.xml" Condition=" '$(Configuration)' == 'Release' " />

<Import Project="..\..\packages\Fody.1.29.4\build\dotnet\Fody.targets" Condition="Exists('..\..\packages\Fody.1.29.4\build\dotnet\Fody.targets') And '$(Configuration)' == 'Release' " />

Of course, this is mainly for simple use cases where you don't want any Fody extension to run in certain build environments.

Alphanumeric answered 15/3, 2016 at 11:40 Comment(2)
this seems to disable all Fody plugins. When I have multiple fody plugins, for example, Costura.Fody and ReactiveUI.Fody, it also disable ReactiveUI.fody. Any suggestion to my case to disable only Costura.Fody?Ingrate
The problem with this method is that on an update of the Fody Extension (for example over NuGet) the condition is deleted againIs
R
6

By default Costura.Fody package only adds one line into your *.csproj file:

  <Import Project="Fody.targets" />

Replace it with

  <Import Project="Fody.targets" Condition=" '$(Configuration)' == 'Release' " />
Reefer answered 15/3, 2016 at 11:44 Comment(2)
The problem with this method is that on an update of the Fody Extension over NuGet the condition is deleted again. I have posted an answer which doesn't have this problemIs
@Apfelkuacha I don't think your option was available at the time when this answer was written.Reefer
I
6

According to Costura Github, a better possiblity is to open the .csproj and insert following line into the first <PropertyGroup>:

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

This way you don't have to modify the file again if there is a package update

Is answered 17/9, 2018 at 10:23 Comment(1)
It will disable whole Fody, not only Costura.Apteryx

© 2022 - 2024 — McMap. All rights reserved.