Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Nuget troubles

Discussion in 'Editor & General Support' started by Feldspatt, May 6, 2020.

  1. Feldspatt

    Feldspatt

    Joined:
    Apr 6, 2020
    Posts:
    1
    Hi,
    I am trying to import a Nuget (https://www.nuget.org/packages/Microsoft.CodeAnalysis.CSharp.Scripting/3.6.0-4.final) into a project, using VS nuget manager.
    At first it seems to works fine, the namespace is recognized (Microsoft.CodeAnalysis), and I can access the library methods (specifically the Csharp.EvaluateAsync()). However, as soon that Unity compile or VSbuilt the project, the package is not recognized anymore and seems to hve disappeared from the references in VS.

    These methods are not essentials to my project but I d like to understand what I am missing. (project settings are set on mono and standart 2.0).

    Any help would be welcome !
     
  2. probbins

    probbins

    Joined:
    Oct 19, 2010
    Posts:
    216
    Unity has a predefined set of assemblies and wipes any new ones as you mentioned.

    Here is an blog about what's going on.
    https://www.what-could-possibly-go-wrong.com/unity-and-nuget/

    They mention the following;

    The difficulties of using NuGet with Unity boil down to the following issues:

    • Unity is built on an old version of Mono. So we are limited in what we can use from NuGet.
    • Unity sets our Target Framework by default to something that will prevent most NuGet packages from being installed.
    • Unity regenerates its Visual Studio solution, which wipes out installed packages.
    • Unity only recognizes DLLs placed under the Assets folder, by default NuGet won’t install packages where we want them.
    I'm also trying to import the same package as you, I've followed various methods without any success due to shear number of dependencies.

    If anyone has had any luck importing it and can offer advice that would be highly appreciated!
     
  3. Akzamutdinov

    Akzamutdinov

    Joined:
    Jan 4, 2021
    Posts:
    6
    Hi all! Facing the same issue. Any success on your side?
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,971