Visual studio references show some libraries not loaded - c#

I have been working maven projects since 2 two years.First of all, I import maven projects to eclipse then
thanks to my pom.xml some dependencies is installed and I see these dependencies on my maven dependencies folder on eclipe project explorer.It connected to my .M2 folder.
Right now , I import a .Net framework project (which is written with C#) in my visual studio program.The solution explorer (references section) show many dependencies(they gives error).Then I found these libraries then I created a folder which is called nugetPackages and I connected my nuget packages manager to that folder(tools/options/nuget package manager/package sources).I reopen my project and libraries on references section does not give any error.My question is where does that libraries names come from ? There are any file like that pom.xml.
I hope I can explain my situation.

Are the libraries (DLLs) that you want to reference in your project NuGet packages or just some framework libraries? If they are Nuget packages they should be described in packages.config file http://prntscr.com/1140xn0 for the classic .NET application (.net framework 4.5 for example) In a .Net Core applications the Nuget packages that are required are defined in the file .csproj file http://prntscr.com/11412iq. In both cases, you can download all required NuGet packages by right clicking on the .sln file and selecting Restore Nuget Packages http://prntscr.com/1140zsk This will automatically create the nugget folder and download all required Nuget packages. If you have manually added dlls you need to navigate to them and select them by right-clicking References - Add reference http://prntscr.com/114142x

Related

Why the nuget dll shows in project root in Visual Studio 2019?

I have an SDK project in my solution. And i need to add a NuGet package ("customLib.net"), which provides the functionality to find the differences between files.
If you create a simple .Net Framework 4.7.2 console application and add this NuGet to it, then it will automatically download it along with all dependencies, including "customLib.redist.windows.x64". As i understand "customLib.net.dll" is an API for .net, and "customLib.dll" (which comes from "customLib.redist.windows.x64" package) is an engine itself, compiled for win-x64. The package is stored in SolutionFolder/packages. And there is a package.config file with all required references. And everything works as expected.
But if to add the same NuGet package to SDK (Class Library) project, which has the same target: .Net Framework 4.7.2, it should also download the NuGet package along with all dependencies. And it does. But it doesn't store the packages in SolutionFolder/packages folder, and there are no any package.config files. It stores them in global NuGet storage on C drive. And the problem is that when i launch the application it throws an exception in runtime:
"Unable to load DLL 'customLib': The specified module could not be found.".
And this dll doesn't exists in output folder. I solved this issue by downloading the "customLib.redist.windows.x64" NuGet package to the project, despite the fact that "customLib.net" already has a reference to this package. This is a little bit weird for me, and here are the questions:
Why, if a "customLib.net" depends on "customLib.redist.windows.x64", it does not copy dependent dll to the output folder? At the same time, the console application copies both libraries.
Why after downloading "customLib.redist.windows.x64" NuGet the "customLib.dll" file shows in my project root in Visual Studio with full path to "C:\Users\MyUsr\.nuget\packages\customLib.redist.windows.x64\1.0.1\runtimes\win-x64"?
As per the description, I can assume that you have .NET standard console application but you added the .Net core class library into it. That's why you are facing such issues.
Because in the .NET core library project, there is no package.config file and references were added directly to the csproj file. As well as packages downloaded to the user's directory, instead of the packages folder.
So, instead of adding a .Net core library, you need to add the .NET standard class library into your project
To know more about it refer to What is the difference between .NET Core and .NET Standard Class Library project types?

How to embed nuget package .Net Standard into a project C#?

I have a project in .Net Standard an it uses several Nugets. for example Newtonsoft.Json. When I want to use this dll in another project, some errors occur and it says Unable to resolve dependencies.
I want to embed nuget into my project. What should I do?
Clear the NuGet cache files. You do this in the following way:
In the toolbar of Visual Studio, navigate to Tools » NuGet Package
Manager » Package Manager Settings.
In the left pane, navigate to NuGet Package Manager » General. Click
Clear All NuGet Cache(s).
To do this, navigate to Tools » NuGet Package Manager » Package Manager Settings » Package Sources.
Delete all packages from the packages folder, located in your project's folder.
Reinstall Newtonsoft.Json to the desired version. Rebuild the project.
Depending on the project and the underlying framework, some versions of .NET do not support .NET Standard. You should check the versions of your project and the .NET Standard NuGet you're trying to reference.
Here you could find data (from Microsoft) on the current support status for .NET Standard.

Nuget Microsoft.SqlServer.Types does not install dlls

I am pulling this project from a git repository that depends on Microsoft.SqlServer.Types which should install msvce120.dll and SqlServerSpatial140.dll. But for some reason it does not install them. They appear in the solution explorer as seen on the image. But the files are not there in windows explorer.
The project was cloned from a git repository. As soon as I tried to build the project, VS started downloading the necessary nuget packages, but this files fail to download. The original repository has these files marked as git ignored.
Where am I going wrong here? I could simply copy and paste the dlls from the original repository but I want to understand why they are not being downloaded or installed.
If you installed this package into a project using the <PackageReference> style of packages (typically found in .Net Standard / .Net Core applications), then the files are not added because there is a lack of support for the install / uninstall scripts used for this function.
Specifically, when installing / restoring this package, there is an install.ps1 script that is supposed to be ran which creates the folders and places the dll's you're referencing into these folders. Again, there is no support for this functionality in the <PackageReference> style of packaging.
This is juxtapose to the packaging style that uses Packages.config which DOES have support for install / uninstall scripts.
You can read more about this here: https://github.com/NuGet/Home/issues/6330

C#, Nuget Can I management Dependency Framework level assemblies?

I'm Nuget packaging with CreateNewNugetPackageWithEachBuild.
Nuget auto installs dependencies another Nuget packages. It works.
But this is not work in Framework libraries like the System.Drawing namespace, UIAutomationTypes assemblies etc.
So when I install my Nuget package, after install that -> and goto "add reference" menu and add framework assemblies manually (System.Security or something, not yet added another DLLs when create project time).
Can I make Nuget pakcages to auto-include the .Net Framework level assemblies when install it?
Make .nuspec file in project folder (be with .csproj file) and define frameworkAssemblies in nuspec file and build it to makes nupkg contains framework level assemblies and auto include when install it

What's the difference between a dll and nuget package?

First of all, I apologize if this is a basic question. I tried looking this up, but for some reason, I got more confused. So, I decided to ask here. Is a dll file and a nuget package the same? Are they both just being referenced in the project?
When you add features to your project via a nuget package, you're just adding files to your project. It can be javascript files (like jQuery), DLLs that your project references (like Newtonsoft JSON), or a whole bunch of things (like Entity Framework or Owin/SignalR) -- anything really.
The advantage of using the nuget package system is that it tracks it all for you. It notifies you if your added packages received an update, it removes the files and unreferences them if you take the package off your project. It handles all of that for you, so you don't have to track the files that the nuget package added, place them in special folders, make sure they get copied in your builds, all that micromanaging stuff.
From the docs, https://www.nuget.org.
"What is NuGet? NuGet is the package manager for the Microsoft
development platform including .NET. The NuGet client tools provide
the ability to produce and consume packages. The NuGet Gallery is the
central package repository used by all package authors and consumers."
A package can contain one or more dlls in addition to other assets such as config files etc.
You can add libraries via reference into your project but you would not notice when they were updated.
NuGet is a Visual Studio extension that makes it easy to pull in not only libraries but components, and most importantly their configuration into your visual studio project. It will help you manage your packages installed on your project and it will notify you when the package has new version released.
Let's say I created my own DLL, I could add my own DLL by reference. However, it won't be available in NuGet until I package and publish it first to make it available at the NuGet Package Gallery.

Categories