How can I publish a package for NuGet that supports Unity (game engine)?
Just follow the instructions in the document . The class library for Unity3D is no different from the regular .NET class library. It just uses a different runtime from Unity3D fork mono .
Also, do you need to install Unity to compile it, or is it enough to target a specific version of the frame?
Yes. If your library uses Unity3D types, the project needs to reference assemblies, such as UnityEngine.dll and UnityEditor.dll , from Unity3D. If your library does not use Unity3D types, you still need to test it with Unity3D. Because earlier Unity3Ds target .NET 2.0 and a subset of .NET 3.5. Therefore, if your library uses functions available only in .NET 4+, it will not work with Unity3D. See Also Using dll .
Itβs better to install Visual Studio Tools for Unity3D , and then you can target one of the Unity3D goals:

Regarding the publication of your package, I think you better publish your package in the Unity3D asset repository , since it is officially supported. You can try this improved version of Unity3D asset storage tools when publishing a package to the asset store.
source share