Nuget dependencies are not installed

I am running a private Nuget server locally in IIS. I create packages and download them all via commadline using nuget.exe (Later I have to put this on the build server, and therefore on the command line). However, there is one problem I'm stuck with.

I am trying to declare dependencies. I am creating a nuspec file in a folder where there is a .csproj file. Then I will manually edit the nuspec file to add it under the metadata tag:

<metadata> <dependencies> <group targetFramework=".NETFramework4.5"> <dependency id="DemoProject" version="2.0.0.0" /> </group> </dependencies> </metadata> 

DemoProject, version 2.0.0.0 is present on the Nuget server. The project for which I am creating a package for MyProj.csproj does not contain references to DemoProjects added to it through Visual Studio. I just want to create a dependency. This sounds strange, but necessary for some initial verification.

Then I run the pack command:

"C: \ nuget \ NuGet.exe" package MyProj.csproj -IncludeReferencedProjects -Prop Configuration = Release

Then I push it to the NuGet server using the command line. When I perform the installation through the command line, then only the MyProj package is present at the installation location.

When I use Nuget Package Explorer and create a package, I can use the package dependency editor to specify the dependency. It requests the URL of my local Nuget server, and then adds the dependency. And when I install this package, it works !!

There seems to be no difference in the generated nuspec file in both cases. Obviously, the Nuget package manager does what I miss.

Any clues?

Details: When I create the lib folder in the package manager console and put my dll manually, lib-> net45-> MyProj.dll, then when I install the package created in this way, it also doesn’t install the dependency. Return to the documentation to read again.

+6
source share
2 answers

I know this does not directly answer your question, but I had a problem with NuGet dependencies, and my solution can give a hint.

DLL # 1 did not have NuGet dependencies. Put it in my personal repo. DLL # 2 related to the NuGet DLL # 1 package. Pushed this to my private repo.

Everything is beautiful and dandy, except from the application project, when I go to "Manage NuGet Packages ...", the NuGet package for DLL # 2 is listed on the "Overview" tab, but it does not show dependencies. I was forced to install both DLL # 1 and DLL # 2 nuget packages. I wanted to install the nuget DLL # 2 package and get the DLL # 1 automatically.

As I fixed it, it was removing all the NuGet packages from the DLL # 2 solution. Then go to Tools> Options> NuGet Package Manager> General. Then set the default package management format to Packages.config, and then clear the "Allow format selection when installing the package for the first time" check box.

Then I installed all the necessary NuGet packages. Now, when I pack it and push it to the server, it shows the correct dependencies when choosing "Manage NuGet packages ...".

nuget pack does not see dependencies because it searches for them in the \ packages folder. This folder did not exist because I used PackageReference to manage packages.

Everything worked after switching to Packages.config for package management.

I know that my problem was not the same as yours, but if you are not using Packages.config to manage packages, it might be related to it.

0
source

Late answer, but the problem with this nuspec is <group targetFramework=".NETFramework4.5"> . I am sure that ".NETFramework4.5" is an invalid target plan. The full list of available Target Frameworks is here .

When working with a section

0
source

Source: https://habr.com/ru/post/976036/


All Articles