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

冷暖自知 提交于 2019-12-21 04:00:52

问题


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?


回答1:


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.




回答2:


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' " />



回答3:


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



来源:https://stackoverflow.com/questions/35266578/how-to-disable-costura-fody-resources-embedding-in-debug-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!