I have a fresh Unity project and following the instructions in Using .NET 4.x in Unity, i’ve downloaded Microsoft.ML.Probabilistic.Compiler NuGet package from the gallery and copied the DLL to Assets/Plugins. After this Unity outputs an error message
Assembly ‘Assets/Plugins/Microsoft.ML.Probabilistic.Compiler.dll’ will not be loaded due to errors: Unable to resolve reference ‘Microsoft.ML.Probabilistic’. Is the assembly missing or incompatible with the current platform?
I downloaded and copied the missing DLL and every following missing DLL dependency
- Microsoft.ML.Probabilistic.dll
- System.CodeDom.dll
- Microsoft.CodeAnalysis.CSharp.dll
- Microsoft.CodeAnalysis.dll
- System.Collections.Immutable.dll
- System.Reflection.Metadata.dll
Unity showed no more errors after adding the System.Reflection.Metadata.dll.
When i add
using Microsoft.ML.Probabilistic;
using Microsoft.ML.Probabilistic.Compiler;
to a script, the project builds fine in both Unity and Visual Studio Community, but when i attempt to use the libraries
using UnityEngine;
using Microsoft.ML.Probabilistic;
using Microsoft.ML.Probabilistic.Compiler;
public class Main : MonoBehaviour {
void Start () {
Variable<bool> firstCoin = Variable.Bernoulli (0.5);
}
}
both Unity and Visual Studio fail with
Assets/Scripts/Main.cs(7,3): error CS0246: The type or namespace name ‘Variable<>’ could not be found (are you missing a using directive or an assembly reference?)
and
Assets/Scripts/Main.cs(7,30): error CS0103: The name ‘Variable’ does not exist in the current context
Adding -r:Microsoft.ML.Probabilistic.Compiler.dll
to Assets/mcs.rsp file generates an error
Microsoft (R) Visual C# Compiler version 2.9.1.65535 (9d34608e)
Copyright (C) Microsoft Corporation. All rights reserved.
error CS0006: Metadata file ‘Microsoft.ML.Probabilistic.Compiler.dll’ could not be found
The project configuration is
- Unity 2018.3.10f1
- Visual Studio for Mac Community
- Build Settings/Platform: iOS
- Player Settings/Scripting Runtime Version: .NET 4.x Equivalent
it makes no difference whether i set
- Player Settings/Api Compatibility Level: .NET 4.x
or
- Player Settings/Api Compatibility Level: .NET Standard 2.0
Other settings are left to their defaults.
I haven’t added the DLLs to the vs-project in Visual Studio as the guide says
Visual Studio regenerates .csproj and .sln files for Unity projects each time they’re opened. As a result, you cannot add assembly references directly in Visual Studio because they’ll be lost upon reopening the project. Instead, a special text file named mcs.rsp must be used:
Create a new text file named mcs.rsp in your Unity project’s root Assets directory.
On the first line in the empty text file, enter: -r:System.Net.Http.dll and then save the file. You can replace “System.Net.Http.dll” with any included assembly that might be missing a reference.
Restart the Unity editor.
This is a cross post with my Stack Overflow question that i’ve received no answers
https://stackoverflow.com/questions/56019411/how-to-install-infer-net-to-unity-2018-3
I would love to use this library and would appreciate any help you can offer.