or-tools: Google.OrTools netstandard packages failing to install correctly in net472

I have some .NET Framework targeted unit tests which I am updating from net45x to net472.

Others of my projects making the adjustment to netstandard2.0 work fine, but the Google.OrTools package is failing to add as a reference to my project following install.

Additionally, all of the run-times are being added as package references, when I think I should only be seeing the Windows package.

Consequently, any references to OrTools bits in the test assemblies are broken. Google.Protobuf package reference seems to be working okay, but I half expected that it would be fine.

For reference, kindly see my OrTools wrappers. Currently published versions are pre-netstandard2.0 updates. I’ve got those updates in the works.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 20 (15 by maintainers)

Most upvoted comments

I have successfully been using the latest NuGet package within a .NET 4.7.2 project. The “trick” is to follow the advice by Scott Hanselmann here https://www.hanselman.com/blog/ReferencingNETStandardAssembliesFromBothNETCoreAndNETFramework.aspx

You need to add the node <RestoreProjectStyle>PackageReference</RestoreProjectStyle> within the first <PropertyGroup> of your csproj file.

Hmm, I am receiving FileNotFoundException and BadImageFormatException exceptions.

I am building for AnyCPU, but I wonder should I build for x64?

System.IO.FileLoadException
Could not load file or assembly 'Google.OrTools, Version=6.9.5841.0, Culture=neutral, PublicKeyToken=600e580726a33e50' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at Kingdom.OrTools.ConstraintSolver.Samples.AspectBasedSudokuSolverTests.Verify_that_aspect_yields_solution()