Why can't I install Ninject 3.2.2 if my project targets MonoAndroid,Version=v5.1? - visual-studio

When installing Ninject I get this log from the Output in VS2015:
Attempting to gather dependencies information for package 'Ninject.3.2.2' with respect to project 'ProjectPhoenix.Droid', targeting 'MonoAndroid,Version=v5.1'
Attempting to resolve dependencies for package 'Ninject.3.2.2' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Ninject.3.2.2'
Resolved actions to install package 'Ninject.3.2.2'
Attempting to gather dependencies information for package 'Ninject.3.2.2' with respect to project 'ProjectPhoenix.iOS', targeting 'Xamarin.iOS,Version=v1.0'
Attempting to resolve dependencies for package 'Ninject.3.2.2' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Ninject.3.2.2'
Resolved actions to install package 'Ninject.3.2.2'
For adding package 'Ninject.3.2.2' to project 'ProjectPhoenix.Droid' that targets 'monoandroid51'.
Install failed. Rolling back...
Package 'Ninject 3.2.2.0' does not exist in project 'ProjectPhoenix.Droid'
Could not install package 'Ninject 3.2.2'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v5.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
========== Finished ==========
I'm working on Xamarin and the same project runs great on Xamarin Studio and other instances of Visual Studio 2015, so I know this is a problem not with the code but with my configuration.

I believe what you're asking is answered here in this other SO question:
How come there's no IKernel implementation in Ninject.Portable
Ninject needs platform specific code to work in each Xamarin Platform, so, for a Xamarin project I would suggest you use the Ninject.Portable NuGet package instead of the plain Ninject one. You also need to install the NuGet in Droid, iOS, Tests and UITests projects to be able to compile all the Solution.
Best Regards

Related

NuGet Framework package with dependencies from Core project

I am trying to reference from a .NET Core 3.1 project, a NuGet package that targets only net40 via the NuGet compatibility shim. The package is added to my project, however the net40 dependencies are not.
The package is structured as:
lib\
net40\
AssemblyA.dll
nuspec:
<dependencies>
<group targetFramework="net40">
<dependency id="PackageB" version="1.0" />
</group>
</dependencies>
Visual Studio's Package Manager lists the dependencies, but when installed, the dependencies are not listed by VS' Preview Changes window and are indeed not installed. PackageB also targets net40.
It does work if I:
Include the dependencies in an "Any" (blank) dependency group as well as under net40
Remove the net40 dependency group and list the package directly under <dependencies> as a flat list
Remove the net40 under lib\ and use a flat list
These are not ideal as it obfuscates the true nature of the targets frameworks. The last two produce NU5128 on pack. For future reference, I should mention that it's required to remove the dependencies from the local cache for even these scenarios to work (surely a bug?).
Any ideas on how to pull dependencies from such packages? Is this simply not supported? A good test example of this is the "Polly.Net40Async" package.
(VS: 16.6.5, dotnet: 3.1.302, PackageReference, Windows 10)
I am trying to reference from a .NET Core 3.1 project, a NuGet package
that targets only net40 via the NuGet compatibility shim. The package
is added to my project, however the net40 dependencies are not.
The nuget package only targets to net40 which means the package is used for net framework 4+.
And by default, Net Core projects cannot use this type of nuget unless the package and dependencies are listed as supporting Net Core or Net Standard.
==========================================
Also, you can notice the info from the Polly.Net40Async nuget package:
group targetFramework="net40" means that if your project targetframework version is 4+, it will install the listed dependencies.
So you should not install this type of packages into Net Core 3.1 project. And it is designed by the author.
Besides, if you change the sub folder of lib in the nuget package to any, you can add the dependencies into the Net Core project.
After all, any means it targets to any framework versions--net core, net standard, net framework. And you just need to remove the condition of the dependency (contention on Net Framework 4+).
====================================
Add more detailed info
Update 1
Actually, Net Core projects can install some nuget packages which only targets to Net Framework.
In my side, the package can be installed in the Net Core project.However, there is a warning which shows it may not be fully compatible with your Net Core project. Although you can use it, there are still some problems just not encountered in special situations.
For the dependencies, since your project targets to Net Core rather than Net Framework, the dependencies will not be installed automatically along with the main package. But you can manually install these dependencies separately through Nuget Package Manager UI.(search them and then install them one by one).
And if condition group targetFramework="net40" is met, it will install these dependencies automatically along with the main nuget package. But since your project targets to Net Core, it will not install them automatically.
As a suggestion, you could search these dependencies on the Nuget Package Manager UI, and then manually install them separately.

Error Could not install package 'Microsoft.Build.Framework 14.3.0'

I have used visual studio 2019, I have added some NuGet packages but it's show error like..
Error Could not install package 'Microsoft.Build.Framework 14.3.0'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v9.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
Note: My Xamarin Binding library(Android) solution target version9.0.
please help me to resolve this issue.
Try by updating your Microsoft.Build.Framework package to the latest version (at the moment it is 16.0.461).
You can check it also here: https://www.nuget.org/packages/Microsoft.Build.Framework/
Once I copied the build task property section from my iOS csproj to my Android csproj.. I got a slightly different message. It asked me to add Microsoft.Build.Utilities.Core.
I then had to add the Microsoft.Win32.Registry 5 nuget then as it tried to install 4.3.0 which my Android project didn't like.

Failed to add MvvmCross 6.0.0

I am trying to upgrade MvvmCross from version 5.x.x to 6.0.0. My core project updated fine but having problems updating my Android project. I am getting the following error:
Summary of time taken to gather dependencies per source :
https://api.nuget.org/v3/index.json - 51.79 ms
Attempting to resolve dependencies for package 'MvvmCross.6.0.0' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'MvvmCross.6.0.0'
Resolved actions to install package 'MvvmCross.6.0.0'
Retrieving package 'MvvmCross 6.0.0' from 'nuget.org'.
For adding package 'MvvmCross.6.0.0' to project 'Listing.Mobile.Droid' that targets 'monoandroid81'.
For adding package 'MvvmCross.6.0.0' to project 'Listing.Mobile.Droid' that targets 'monoandroid81'.
Adding package 'MvvmCross.6.0.0' to folder 'C:\VSProjects\Listing\packages'
Added package 'MvvmCross.6.0.0' to folder 'C:\VSProjects\Listing\packages'
Added package 'MvvmCross.6.0.0' to folder 'C:\VSProjects\Listing\packages' from source 'https://api.nuget.org/v3/index.json'
Install failed. Rolling back...
Package 'MvvmCross.6.0.0' does not exist in project 'Listing.Mobile.Droid'
Executing nuget actions took 2.66 sec
Failed to add reference to 'MvvmCross'.
Reference unavailable.
Time Elapsed: 00:00:03.0575672
========== Finished ==========
I am not sure if this a NuGet problem, MvvmCross problem or something else. I have removed all references to MvvmCross 5.x.x to no avail. I have removed the contents of my packages folder and still nothing. Did anybody run into this issue?
I am using VS2017. I eliminated the problem by deleting. project.json.lock. It might have been a left-over from when I converted the project from VS2015 to VS2017 project setup. Once removed, I was able to add references for all require MvvmCross packages.
your project targeting .framework 4.5 , if you want use 6.0.0 you have to create cross-platform solution targeting .net standard 1.0 and above

Is there a way to install a NuGet package without all of its dependencies?

In a Visual Studio 2015 C# project, is there any way to selectively install the components of a NuGet package? (Aside from manually adding references)
Background:
I have been using the Microsoft.CodeAnalysis.CSharp package recently. This package contains several libraries that I need:
Microsoft.CodeAnalysis
Microsoft.CodeAnalysis.CSharp
It also installs many libraries that these are dependent on. For the features I am using, I only need these two:
System.Collections.Immutable
System.Reflection.Metadata
But it also installs many more libraries that I never need:
System.AppContext
System.ComponentModel.Composition
System.Console
System.Diagnostics.FileVersionInfo
System.Diagnostics.StackTrace
System.IO.FileSystem
System.IO.FileSystem.Primatives
System.Numerics
System.Security.Cryptography.Algorithms
System.Security.Cryptography.Encoding
System.Security.Cryptography.Primitives
System.Security.Cryptography.X509Certificates
System.Text.Encoding.CodePages
System.Threading.Thread
System.Xml
System.Xml.Linq
System.Xml.XmlDocument
System.Xml.XPath
Systen.Xml.XPath.XDocument
Is there someway I can check the boxes of the libraries I want when installing the package?
According to the docs , there only -IgnoreDependencies command could help us ignore all dependencies. We could not ignore part of dependencies.
But you could implement your requirement with -IgnoreDependencies, please refer to following steps:
Install the Microsoft.CodeAnalysis.CSharp package without any dependence:
Install-Package Microsoft.CodeAnalysis.CSharp -IgnoreDependencies
Install the dependence package Microsoft.CodeAnalysis. Common package without any dependence:
Install-Package Microsoft.CodeAnalysis.Common -IgnoreDependencies
Install the dependence package System.Collections.Immutable and System.Reflection.Metadata package:
Install-Package System.Collections.Immutable
Install-Package System.Reflection.Metadata
If you do not need to use the dependences of “System.Collections.Immutable”and “System.Reflection.Metadata”, you can also use the same option to ignore dependences.

NuGet package without assemblies complains about lack of assemblies

I'm creating a content-only NuGet package (e.g. no DLLs, just text files in this case). When I install the package, I get this error message:
Install-Package : Could not install package 'CodeGenerator.Templates.EF6-CQRS-Aurelia 1.0.2'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.1', but the package does not contain any assembly references or
content files that are compatible with that framework. For more information, contact the package author.
This is all true, but I don't want to target any framework for this package -- how can I accomplish this?
The package is here: https://www.nuget.org/packages/CodeGenerator.Templates.EF6-CQRS-Aurelia
I had the same problem but with only a build target (and no assemblies).
Just adding an empty lib folder to my root package directory fixed it.
(Maybe a bug in NuGet. I have submitted an issue.)

Resources