Convincing Nuget that I've met a dependency from another package - nuget

I have a project where I'd like to use https://www.nuget.org/packages/Bootstrap.Datepicker/, so being a good modern developer I tell VS to add that nuget package. Which is cool. But along with it comes Bootstrap 2.3.1, which I know is a dependency of that package. But my project already has the Bootstrap Less Source (3.2.0.1) package installed, and I'm concerned about having two different "instances" of the "same" package in my project. Another developer on my team has pointed out that any and all Nuget packages that are based on bootstrap probably will require the default one, not the less source package we're using, even though that works best for us.
Is there some way in nuget to tell it to ignore dependencies, or convince it that instead of the dependency it's expecting, it's been met in another way?

Related

Cannot use home-made NuGet package

I'm investigating using NuGet internally to share an assembly used across multiple solutions. Despite the documentation making it look simple, I'm just getting a faceful of problems. I have two questions at this stage:
1) When I create the package, NuGet reports it as having 'no dependencies'. In fact, the assembly's project has quite a few dependencies on other (official) NuGet packages. I assumed that NuGet would spot this. Is there something I need to do so that NuGet knows my assembly itself has NuGet dependencies?
2) When I attempt to add the package to a project in another solution, it doesn't actually add the dll to the project (i.e. in the project's References). The package manager GUI lists the package in the installed list, but doesn't show a 'Manage' button, as it does for other packages. Instead, it just shows a 'Uninstall' button. So it's as if the overall solution is now aware of my package, but I can't add it as a reference to any projects, which is obviously of no use. This happens regardless of whether I install using the GUI or the command line. Does anyone know why this might be happening?
Thanks in advance.
For issue 1, if you are using nuget.exe pack and your project installed certain packages, these packages will be added as dependencies. If the packages are installed to another project that the main project is referencing, do nuget.exe pack -includereferencedprojects. For more information, please refer to http://docs.nuget.org/docs/reference/command-line-reference#Pack_Command_Examples.
For issue 2, you have probably installed a solution-level package, which does not have Content or Lib folder inside. If you install a project-level package, you should be able to see the manage button.
Hope this helps.

Requiring another package from your package in Package Control?

I'm developing a plugin for SublimeText that uses the FullScreenStatus plugin. Is there a way to set it up so that if someone installs my plugin, the FullScreenStatus plugin will be automatically installed as well, like a requires directive? Every other package manager I know of can do this, but I couldn't find anything in the docs and no other package I looked at is trying to require another package.
Since FullScreenStatus is MIT licensed, I could just include it in mine, but is there a way to require it without doing that?
You either have to bundle it yourself, or explain in the install message and README there is an external dependency. If you feel like adding to the discussion on dependency management, feel free to contribute to https://github.com/wbond/sublime_package_control/issues/166. Some initial work can be seen at https://github.com/wbond/sublime_package_control/issues/291#issuecomment-14028788.

Selective installation by using NuGet Package

I have created versions of NuGet packages,uploaded and it is working fine.
I have set of libraries in my package which has been populated in different directories inside the package.
Some users might require a particular directory of my NuGet package, and some of the libraries might not be needed. While installation I should prompt users that which part they need to install.
One Solution:Logical seperation of packages may be one solution. Like packing libraries in separate packages, and required packages can be installed.
But If it has been made selective installation, then it would be more easier. I have no idea whether NuGet have such an option. Any help would be appreciated.
NuGet has support for framework versions and platforms using conventions, you can read up on them in the docs. You can group them by target framework version or by target framework profile.
If you want to selectively install libraries, you are saying you want to selectively install dependencies: you should split them up in separate NuGet packages and declare your dependencies. These dependencies also can be grouped.
If your condition cannot be defined using framework version or profile, you should come up with your own entry-level NuGet packages and bring down the proper dependency chain (or use PowerShell hooks for this).

Varying dependencies depending on target project type

I have a package Ninject.Extensisons.Wcf which shall be installed differently depending on the type of the project to which it is installed. In the case where WCF is hosted in IIS (any project containing global.asax) a second package Ninject.Web.Common needs to be installed together with the package. For all other project types such as libraries, Console, WinForms, WPF applications this package should not be installed.
Is it somehow possible to achieve this e.g., using a powershell script? Or do I have to deploy two different packages in this case?
Unfortunately the current nuspec file does not provide for managing dependencies based on project type. We currently support targeting different framework versions, but that doesn't apply in your situation.
It is recommended that all dependencies are handled using package references. Although it would be technically possible to download and install a package using a PowerShell script, this is not supported and will most likely break in future versions.
First determine if it would actually be a problem to reference a web package in a non-web project. Just because assemblies are referenced, if they are not used, it should not have an impact.
If it turns out that having the web dependency causes undesirable side-effects, then you'll need to create separate packages.
I would split up your package into logical pieces. As you state, you have a package that is used by non-web projects. Web projects require a dependency on a different package.
So now you have 2 logical packages:
MyProject
MyProject.Web
MyProject (dependencies)
SomeOtherPackage
So a user would Install-Package MyProject for non-web projects, and Install-Package MyProject.Web for web projects.
At this point you would be done and everything would be fine. But I think you should consider another step. One of the issues I see with these split packages is that I have to figure out which particular package I need to install. I have to know that I need the "Web" version.
At this point, determine the typical use case for your package. If 90% of your users will be installing the Web version, then I would make a "meta" package that simply has dependencies for your common packages.
In your case I would make 3 packages:
MyProject (meta package)
MyProject.Web
MyProject.Web
MyProject.Core
SomeOtherPackage
MyProject.Core (common non-web package)
By creating the "meta" package, you can reserve the "short" package name for the most common case. This meta package only has dependencies to other packages.
A good example of this is the SignalR package.
Hope this was helpful.

Should I add the dll of my third libraries in the version control repository?

Version control Best practices.
When developing a program, I use third party libraries, NUnit and others.
I want to share the sources of this program hosted on http://www.codeplex.com/ or http://code.google.com/hosting/.
What are good practices as regards third libraries?
Should I add the dll of my third libraries in the version control ?
Thank you,
With the introduction of NuGet you have a different way to do this.
See this post by David Ebbo: Using NuGet without committing packages.
Basically you use NuGet to download and add package references to the libraries you want (assuming there's NuGet packages for the libraries you need), but do not add the Packages folder to your repository.
Instead you modify your pre-build step of the projects that require packages so that they automatically download the packages required if they're not present.
Testing has shown that this adds a minor delay to the build process when checking if the libraries are present, so this may or may not be good enough for you.
We always do especially if we are linking against a specific version, we have an NUnit folder for example and then a version folder within it.