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. Dismiss Notice

Unity3D removes successfully installed NuGet package reference

Discussion in 'Scripting' started by BullDoze, Nov 14, 2020.

  1. BullDoze

    BullDoze

    Joined:
    Jun 13, 2018
    Posts:
    14
    Ok, I am desperate:
    I am trying to access a MariaDB installation from C# under Unity3D using Rider2020.
    After installing the MySqlConnector 1.1.0 (or 1.0.0 as well) via NuGet I can see the package has been added.


    However when I try to use the "using" directive for it, the system can at first find it.



    But when I save the file, the entry is deleted from the references! And subsequently the buid fails.



    I have been experimenting for 4(!) days now un/reinstalling both VS2019 and Rider. Without any result. I have to note that this does not only concern this package but also MySql.
    So it probably is not related to the package. The removal only happens when I opened the source from the Unity3D editor. If I just use Rider to edit the source file, saving does not remove the reference. So it seems obvious that Unity is causing this.

    I am aware of this StackOverflow question: Nuget package installed but references not resolved but trying the approaches there did not solve my problem.

    Any ideas?

    Many thanks
    Olaf
     
  2. rubcc95

    rubcc95

    Joined:
    Dec 27, 2019
    Posts:
    222
    As far I know Unity does not support NuGet... But I've used this package sometimes NuGetForUnity
     
  3. BullDoze

    BullDoze

    Joined:
    Jun 13, 2018
    Posts:
    14
    ok rubcc95, I will refrain from kissing the ground that you have walked over... and just say that this saved my ass BIG TIME!
    Many thanks ... may the Force be with you! :)
     
  4. BullDoze

    BullDoze

    Joined:
    Jun 13, 2018
    Posts:
    14
    ...one more thing: how did you kno NuGet was not supported by Unity?
     
  5. rubcc95

    rubcc95

    Joined:
    Dec 27, 2019
    Posts:
    222
    Unity manages your project properties and your assembly csproj files. When unity compiles both of them use to be modified... and csproj has your references... so you can't add a reference, since unity will destroy it. You need to at it to your assets as a dll.
     
  6. CortiWins

    CortiWins

    Joined:
    Sep 24, 2018
    Posts:
    142
    Maybe you could write an AssetPostprocessor and use OnGeneratedCSProject to manually insert the nuget-reference into the project file.