Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to add a filter for certain compilation targets? #5

Open
JesseRacine opened this issue Nov 15, 2016 · 2 comments
Open

Possible to add a filter for certain compilation targets? #5

JesseRacine opened this issue Nov 15, 2016 · 2 comments

Comments

@JesseRacine
Copy link

Is it possible to make this so that it does not virtualize methods if your build is set to "Release", but make it work if the build is set to "Debug" or the like?

@philippdolder
Copy link
Owner

I don't see a way my plugin could solve this by itself without implementing a hack.
AFAIK Fody doesn't support enabling of addins on a conditional basis. But I need to check with @SimonCropp.

Currently I can only propose to try a manual modification in your csproj file.

In this part

  <Import Project="..\packages\Fody.1.29.4\build\dotnet\Fody.targets" Condition="Exists('..\packages\Fody.1.29.4\build\dotnet\Fody.targets')" />
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..\packages\Fody.1.29.4\build\dotnet\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.1.29.4\build\dotnet\Fody.targets'))" />
  </Target>

surround the <Import> tag with a <ImportGroup /> adding the condition to enable it for debug builds only.

in the <Target> tag add the Condition attribute to also enable it for debug builds only.

So far for the technical part.

My more general question to you is: Why would you want to do this? I can imagine you run your tests against debug builds, but use Release builds for production. I prefer to always deploy exactly the same binaries to production as you test in your CI build, therefore I ALWAYS build everything in Release, except when working in VS.

@philippdolder
Copy link
Owner

fody can't do it. see reply by @SimonCropp https://twitter.com/SimonCropp/status/799161076600467456

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants