Home > Posts > Fix: “A numeric comparison was attempted” at VS build (Costura.Fody)

Fix: “A numeric comparison was attempted” at VS build (Costura.Fody)

After upgrading from Visual Studio 2017 to Visual Studio 2019 I was able to update NuGet packages Fody and Costura.Fody of a solution that needed them (to package assembly DLLs inside console EXEcutables) and the solution was rebuilding fine.

However after I synced the solution via a Git repository on another machine and installed the newer Visual Studio there too, I rebuilt the solution in order to fetch/rebuild NuGet packages too and although everything seemed to rebuild fine, when I was using a plain build instead of a rebuild all I was getting at Errors dialog for each project that was using Costura.Fody:

Error

A numeric comparison was attempted on "$(MsBuildMajorVersion)" that evaluates to "" instead of a number, in condition "($(MsBuildMajorVersion) < 16)".  

To fix this I had to uninstall and reinstall Costura.Fody NuGet package (it wasn’t needed to uninstall/reinstall the Fody NuGet package itself) on the solution’s projects that were using it and then all was rebuilding/building fine again on that other machine.

  1. 2019/12/17 at 20:30

    I’m seeing this problem myself, but your solution didn’t work for me. The only thing that works is building the solution exactly three times in a row. After that, any combination of Clean and Rebuild works. However, building from a fresh repository (or doing “git clean -fxd”) brings back the build errors.

    • 2019/12/18 at 20:42

      Since Fody (and Costura.Fody too I think) update often, maybe you could try to update those NuGet packages in case it gets solved by itself. Have you upgraded them at all since it stated occurring?

  1. No trackbacks yet.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.