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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Nuget with UnityVS

Discussion in 'Scripting' started by jayw, Apr 14, 2015.

  1. jayw

    jayw

    Joined:
    Aug 8, 2012
    Posts:
    7
    I am using UnityVS and want to use nuget pacakges. However every time my project is regenerated I lose the packages. Is there a way to add references to external libraries with UnityVS without losing them every time they're regenerated?
     
  2. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    I think you can do this by adding a new project to your solution, alongside the four default ones (Unity.CSharp, Unity.CSharpFirstPass, etc). Add the NuGet packages to this new project and then have the other projects reference the new project.
     
  3. jayw

    jayw

    Joined:
    Aug 8, 2012
    Posts:
    7
    I didn't realise UnityVS would cater for extra `csproj`s automagically. Thanks a lot, I will give it a try.
     
  4. jayw

    jayw

    Joined:
    Aug 8, 2012
    Posts:
    7
    Thank you @makeshiftwings the .sln file keeps the references to the CS Projects.
    However I can't add reference one of those CS projects without UnityVS' Generate Project Files menu item removing them each time. Any way to keep them?
     
  5. jayw

    jayw

    Joined:
    Aug 8, 2012
    Posts:
    7
  6. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Adding the DLL to Assets like you did will work, but also you can add a project to the solution, and just not click "Generate Project Files", as that does indeed delete and re-create the solution. I usually only click that if somehow the project files stop working. But if you don't click that, you can add and remove files within Unity and it will automatically regenerate the main csproj files but it won't regenerate the sln file.