We have .Net 4.7.2 (C#) project "Common" (base project), and this is consumed by C# project "API".
API consumes Common.
I would like to add Microsoft.ML functionality to Common, and API will call into Common to exercise that functionality - but I do not want to add the ML nuget packages to API.
This should be fine as all the dll's from Common should get copied into the bin directory of API on build.....
...there are some snags though. It seems that if Common does not actually refer to any types in a referenced dll then the build process skips the copy and API does not get the dll in it's bin directory. A hack is required to work around this as detailed in an answer to:
stack overflow question - MSBuild doesn't copy references
here is my hack that causes all dependent dll's to get copied into bin/
// NOTE - this method present so that the build process sees some use of types
// that are in dependant libraries - this causes those libraries to get copied to the bin directory
// of any project that references Domain - e.g. Api, PP etc.
public static void Dummy()
{
var type = typeof(Microsoft.ML.Trainers.SgdNonCalibratedTrainer);
Console.WriteLine(type.ToString());
}
...this works, except that native dll's are missed. In order to work around that I have added the dll as a file to the project and set "Copy if newer" to true.
...this is nasty! ...is there a better way?
Specifically my issue is with nuget package: "Microsoft.ML.CpuMath". Within this package is "Microsoft.ML.CpuMath.dll" and also "CpuMathNative.dll".
How to I end up with CpuMathNative.dll in Api/bin, without adding it (or any Microsoft.ML.CpuMath package) to the Api project?
This should surely be possible as surely it is quite normal to encapsulate functionality in a Common project.