I installed some ASP.NET packages (FirebaseStorage.net if it matters) via Nuget in my game's project in Visual Studio.
Visual Studio itself shows no errors, as it probably understands using Firebase.Storage internally, but when it comes to Unity, it says
The type or namespace name 'Firebase' could not be found (are you missing a using directive or an assembly reference?)
I believe this happens because I installed this package through the Nuget Package Manager, inside Visual Studio, and it probably has nothing to do with Unity, so Unity doesn't find it.
How can I make Unity understand packages from Nuget?
If you want to use a Nuget package in Unity you have to add it manually.
How you can do this:
create a separate temporary Visual Studio project
install the Nuget package
copy the dll's from the temporary project to a "plugins" folder in the Assets folder of Unity.
Unity now builds the project with the dll's of the Nuget package
However, now comes the hard part of having to do it manually: if the dll has dependencies on other dll's, these will also have to be added manually. That is the big advantage of Nuget package manager.
Related
I got an issue working with Nuget packages and local projects.
I am working on a .Net Framework solution, with many projects and many of them are packaged with Nuget in a private repository. I am using PackageReferences to resolve nuget packages. I am working on solution with that kind of dependency tree.
StartUpProject
Project1(LocalProject)
Project2 v1.0.0(NugetPackage)
Project3 v1.0.0(NugetPackage)
Project3 v1.0.1(LocalProject)
When I want to debug or upgrade functionality of packaged project, I remove Nuget package and add that assembly as local project.
When I am navigating in the source code if I try to go to some function from the modified project, Visual Studio open the code as external assembly and does not resolve like local project.
Maybe the problem is other Nuget package (Project2) depends from I removed Nuget package (Project3) and Visual Studio still resolving that assembly as Nuget package.
The error that Visual Studio throws at compilation is CS0433: The type 'MyType' exist in both'Project3 , Version=1.0.0, ...' and in 'Project3, Version=1.0.1, ...'
What is way to work in that cases?
Is any way to force to use local project than dependency nuget package?
Thank you!
Background: I am using Visual Studio 2019 Professional Version 16.11.15, and NuGet Package Manager 5.11. I was provided some 3rd party assemblies to use for my .NET Standard 2.0 class library. These dlls were installed locally on my machine by an installer. I added them to my project via "Add Project Reference". Here's a screenshot of them working.
Goal: Create a NuGet package for my .NET Standard 2.0 class library to be used internally by our dev team. It should encapsulate these 3rd party dlls as part of it. But I keep running into dead ends.
Important note: Xceed does not host these .NET Standard assembly versions on nuget.org, purposefully making my life difficult it seems...
I have tried:
Using the "Generate NuGet package on build" in the Package section of the project properties. This option does not attach the 3rd party assemblies with it. This includes setting the Copy Local option to "Yes".
Adding these 3rd party dlls to their own NuGet packages via NuGet Package explorer following this answer. I tried several different flavors of folder structures:
placing the dll at the root
placing the dll inside a "lib" folder
placing the dll inside a "lib/netstandard2.0" folder
None of these options worked when adding the NuGet packages to my project. The references to the assembly namespace weren't resolving in the code.
Has anyone had any success doing something like this before?
It turns out I was running into the problem of the NuGet packages not refreshing when updating it. I followed this the first part of this answer to solve that.
When using the folder structure "lib/" inside the NuGet package, I was running into this warning:
Warning NU1701 Package 'Xceed.Document.NETStandard 2.3.2' was restored using
'.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2,
.NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1,
.NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8'
instead of the project target framework '.NETStandard,Version=v2.0'.
This package may not be fully compatible with your project.
Once I updated to use "lib/netstandard2.0/" inside the NuGet package, I was able to add the NuGet packages to my library successfully and compile. Great success!
I'm trying to use the Math.net extension for Visual Studio 2015 with C#.
Unfortunately, after installing the package with
PM> Install-Package MathNet.Numerics -Version 3.20.0
I cannot find it anywhere in the Add References menu. I searched Assemblies->Framework and Assemblies->Extensions and COM, but it's not there
I wouldn't mind the just adding the DLL to my project, but I cannot find the DLL anywhere on https://numerics.mathdotnet.com , all the links take me to the NuGet package manager.
Also, do I need to distribute the MathNet dll with my application if I add it through the package manager, or does it build internally with the application?
Sorry, new to .net library management
I see that when I ran the command line, it added a packages folder to my project folder. Which has a few different versions of the library per .net version. Which I could browse to with Add Reference->Browse->Browse
Is this the correct way about adding a third party library?
Symptoms
I've been attempting to fix my Xamarin forms solution in Visual Studio 2017 RC1 that was generated as a brand new template. While both the android and iOS sub solutions have all their .dll references properly referenced, my UWP (Universal Windows) sub solution seems to be missing essential references to the following .dll files:
'System'
'Xamarin'
'Application'
'Linq'
I was able to locate the .dll references for 'System' and 'System.Linq', in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework, but I'm having trouble locating the specific 'Xamarin' reference for UWP (Windows). I am fairly certain finding the 'Xamarin' reference will also resolve the 'Application' reference as I believe it is a derivative of 'Xamarin'.
Attempted fixes
1. Clean solution
Result: Clean immediately cancels, errors regenerate
2. Create new solution
Result: No change
3. Reinstall Visual Studio 2017 (Several times) and then create new solution
Result: No Change
Specific Error(s)
CS0246 The type or namespace name '-insert reference here-' could not be found (are you missing a using directive or an assembly reference?)
This is happening in project platform -solution name-.UWP in the App.xaml.cs file.
I had the same problem. Unloaded and reloaded the UWP project and suddenly all my lost nuget references appeared (Xamarin.Forms, Microsoft.NETCore.UniversalWindowsPlatform, sqlite-net-pcl, ...)
Turns out the Nuget package needed to be updated.
To do this, use the "Solution Explorer" Window, right click references -> Manage NuGet Packages. A new window will pop up allowing you to update and install NuGet packages.
Alternatively, you can navigate to the Package Manager with Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution.
You can also use the package manager console and use the command: Update-Package to update all packages.
I am creating a NuGet package from one of my projects using -IncludeReferencedProjects.
When I check the nupkg afterwards with the NuGet Package Explorer I see all referenced libraries inside the lib folder.
After installing the package in another project one of the before mentioned projects is not referenced.
I don't get any error messages when installing or packaging. Does anyone have an idea, what might cause this or is there a way to debug it somehow?
The Nuget package is hosted in our Team Services repository.
I found the answer. The problem was that the assembly name was ending with .Resources for some reason .Net or Visual Studio or NuGet can't handle that.