Do I need to add DLL's that are marked as dependencies to the nuget lib folder - nuget

I have a package and nuspec file that I build by copying the dll for the assembly in question into a lib folder which is in the same folder as my nuspec file. This all works fine and dandy, no issues here.
I have a second package which references the first via nuget so to build it's package I followed the same process but added in a dependency element into the nuspec file. When I do my copy from release to lib it also takes the dependent dll.
Since this is marked as a dependency can I remove this from by lib folder (I want it to be downloaded via nuget, not included in the current package).

I'm not sure I got your scenario exactly, but in general I could say: Depending on how you create your NuGet packages, you might not even have to specify the dependencies. Given a Visual Studio solution with the following structure:
* Solution1
- Project1
* projectfile1.csproj
- using external libraries through NuGet
- project reference to Project2
* nuspecfile1.nuspec
- Project2
* projectfile2.csproj
* nuspecfile2.nuspec
If you run nuget pack projectfile1.csproj, any NuGet packages included in Project1 will automatically be included as dependencies in your NuGet package, even if you haven't specified the dependency in your nuspec file. These dependencies will then also include the versions of the external libraries at the time of creation of the package.
As of NuGet 2.5, there is also a new feature to automatically resolve dependencies between projects in the same solution. With v2.5 you can run the following command:
nuget pack projectfile1.csproj -IncludeReferencedProjects
This will also result in a NuGet dependency to Project2. And in case Project2 isn't exposed as a NuGet package (i.e. it has no nuspec file), the Project2's dll will be included as a file in Project1's NuGet package.

After doing some testing it turns out that adding a dependency does not require the dll to be in the lib. The dependency assumes it will be resolved by Nuget. This can be confirmed by creating a new package file via the nuget GUI and adding a few dependencies. Note how they do not show up in the lib folder after save.

Related

Automating .net framework package installation: resolving package dependency on other packages

Long story short: I am trying to automate package .net framework nuget updates in a solution via VS2019 package manager console and i can't get a package dependencies on other packages (Though i know the data is available because you can see it in the UI).
Long story long: I am trying to automate nuget installation for .net framework and i chose to use the package manager console in visual studio (If there is a preferred option i would love to hear about it). The problem i am trying to solve is this:
Problem input: Package A: version 1, has dependency on package B version > 1. version 2 has a dependency on package B version > 2. Package B: version 1. version 2 has a breaking change. Package C: version 1, has dependency on package B version > 1.
Problem I am trying to solve: I have these 3 packages referenced by the same project. I want to upgrade package A to version 2. Its dependency is package B version > 2. Running package A update to version 2 (via package manager UI or console) will update package B to version 2. Boom! - package C will detect it is missing a method it requires from B version 1 only at runtime!
What i am trying to do - Scripting the installation process prompting the user for these type of dependencies.
My problem - For that i want to get a package dependencies and i can't find the way to do it using the package manager console.
Appreciate some help :)
For that i want to get a package dependencies and i can't find the way
to do it using the package manager console.
We cannot use nuget manage console to get the package dependencies.In addition to UI viewing nuget package dependencies, we can get the dependencies from csproj file in the nuget project A. This is the related content in A.csproj file:
<ItemGroup>
<PackageReference Include="Antlr">
<Version>3.5.0.2</Version>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging">
<Version>3.0.0</Version>
</PackageReference>
</ItemGroup>
Another is that you can view package dependencies is through the nuspec file which is created by command nuget spec (if you use nuspec files to enforce dependencies), which are the documentation you use before packaging the project.
Scripting the installation process prompting the user for these type
of dependencies.
Note: In view of your situation, you cannot use two versions of the nuget package in the same project which will cause version conflict.
Suggestions:
I wonder why you deleted the method required by C when you upgrade B. Basically, when we upgrade and modify the package, we will new features to it without removing the original data and methods to prevent references to other dependent packages in the project from using the corresponding methods.
So you could restore the methods required by the C package in the Package B version two.
If you make a major change to package B version2 and the steps of restoring the method are a bit complicated, I suggest you can make a copy of package B specifically for C packages.
Just rename the Package B version 1 and referenced by Package C to distinguish it from the second version of the B package.
Hope it could help you.

Install child modules' 3rd party dependencies to local maven repo

I have a big maven project which has smaller child modules. I imported the project using m2e eclipse plugin and i got lots of compilation errors in eclipse.
After i built the whole project using mvn clean install some of the errors are gone(because maven plugin is able to find those dependencies in local repository and reference them from there), but the child modules still show lots of compilation error because the child modules' dependencies are missing from local repo. The dependencies are getting copied in a /lib folder inside target folder of child module.

Updating Pre-release dependencies using nuget

I'm currently develop a set of libraries that progressively add more features.
For example, in my solution, I have a Foo project which defines some basic feature set, an additional project, Foo.Web, for web specific implementations and Foo.Web.Tokens for even more specific features. Foo.Web.Tokens depends on Foo.Web which depends on Foo.
I'm attempting to build separate nuget projects so a user only needs to reference those dependencies they need. I'm versioning the assemblies with GitVersionTask, so after build, they all get the same version number and I'm using the replacement tokens for nuget when building from a project so that the nuget packages all have the same version number.
My problem is that when I try reference a prerelease version of either Foo.Web or Foo.Web.Tokens nuget is unable to resolve the dependency on Foo. If, for example, I have published a 1.1.0.0-alhpa0001 package for each of the assemblies, when I try and update Foo.Web, nuget shows this error:
Install-Package : Unable to resolve dependency 'Foo (≥ 1.1.0.0)'.
Using the -Pre argument doesn't change this. A Foo.1.1.0-alpha0001.nupkg does exist but I feel like nuget won't resolve it because it's not a stable version, and I'm letting nuget automatically detect the dependencies from the solution using the following command:
.\.nuget\NuGet.exe pack source/Foo.Web/Foo.Web.csproj -Build -Version 1.1.0.0-alpha0001 -symbols -IncludeReferencedProjects
How do I properly allow the Foo.Web prerelease package reference the Foo prerelease package of the same version?
The IncludeReferencedProjects option seems to pull the version from the assemblyinfo.cs of the referenced project.
setting the AssemblyInformationalVersion attribute to the desired nuget package version seems to work as you want it to.
eg
[assembly: AssemblyInformationalVersion("1.1.0-alpha0001")]

How to create standalone jar file for elastic4s from sources?

I'm trying to create a standalone jar file from the elastic4s sources on github. I've used sbt compile as detailed on the github page, but I can't find the jar file.
How do I use sbt to create the jar file so I can import it into my projects as a dependency?
The compile task will only compile the project.
> help compile
Compiles sources.
If you want to create a jar file and use it as a dependency in your project, you have two ways of doing that.
Unmanaged dependency (not recommended)
Unmanaged dependency run +package, which will create a jar file for each supported scala version, which you can use in your projects as an unmanaged dependency. Copy the package-generated jar to lib folder in your project.
The jar files will be located in target/scala-2.11 and target/scala-2.10, depending on the Scala version you want to use it with.
Publish to Local Repository (recommended yet imperfect)
If you want to include your custom-built elastic4s, as a managed dependency, you have to run +publishLocal. This will do the same as above, but additionally it will publish the artifact to your local repository. Assuming you've built it with version := "1.2.1.1-SNAPSHOT", you can include it in your project by just adding:
libraryDependencies += "com.sksamuel.elastic4s" %% "elastic4s" % "1.2.1.1-SNAPSHOT"
What makes the approach imperfect is that once you shared the project on GitHub (or any other project sharing platform), people will have to do publishLocal themselves to be able to build your project. The dependency should therefore go to one of the official binary repositories so when a dependency is needed, it's downloaded from Internet. Consult Publishing.
What is the + character in front of the commands
The + in the commands is for cross-building, if you don't use it the command will be executed only using scalaVersion declared in the build.sbt of the project.

Is there a way to create a nuget pack specifying dependencies of .NET libraries?

One of my libs has a dependency on System.Configuration but this .NET lib is not included by default in most of project types on Visual Studio. Is there a way to instruct NuGet Package Manager to add this .NET reference when installing my lib?
You can use the frameworkAssembly element in your package's nuspec file. This will cause NuGet to add a reference to the project when your package is installed.
<frameworkAssemblies>
<frameworkAssembly assemblyName="System.Configuration" />
</frameworkAssemblies>