I made library which is nuget availiable. Let's call it A. Now I would like to create other solution which will use this library and extend it's API by adding fluent api.
My library project type (A) is dll portable with targets: .Net Framework 4.5, Windows 8, ASP.NET Core 1.0
Now, I was trying to create another project in different solution(let's call it B) with same targets (still .dll) However, i can't get manage to make it work. When installing A lib by nuget, it throws:
Could not install package 'System.Collections 4.0.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', 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.
How to fix it?
Related
Getting error while trying to install a Nuget Package
I'm trying to install a pakage and get the following error:
NuGet\Install-Package Microsoft.Windows.WinMD -Version 1.0.210629.2'
NuGet\Install-Package : Could not install package 'Microsoft.Windows.WinMD 1.0.210629.2'. You
are trying to install this package into a project that targets '.NETFramework,Version=v4.7.2',
but the package does not contain any assembly references or content files that are compatible
with that framework.
Please help
Do I understand correctly that you want to write a .net wrapper over a C++?
If so, this is nuget package does not contain dll files. Most likely you need to build the C++ library first and add build result as content in your project.
This nuget package framework is tagged with native.
nuget: Microsoft.Windows.WinMD - Frameworks
The native framework tag is for C++ projects.
DevBlogs: Support for Native Projects
Conclusion: This package can not be consumed or used by any C# project.
However, in the nuget used-by tab of that package is a reference to a C++ github project that uses this package and is described as
C# language projection for the Windows Runtime
You may have a look at that.
I created a ASP.NET Core web application. In this solution I also have a .NET Standard 2.0 project.
First I added a reference from .NET Standard project to a dll (.NET framework 4.6.1) manually without any issues and it works fine. I have then created a Nuget package for .NET framework dll, and tried to install this package in .NET Standard project.
I got an error
Package xxx was restored using .net framework, version = 4.6.1. instead of project target framework '.NET standard, version = v2.0'. This package may not be fully compatible with your project.
I am confused, how come i can use a .net framework assembly when referenced manually, and when it is installed via nuget i receive this error.
Further more, when i install this nuget in .NET Core 2.1. project (same solution) i get the same error.
This warning is specific to NuGet. When manually adding a dll, no part in the build checks the target framework of that dll (in theory, most dll files should carry a TargetFrameworkAttribute assembly metadata but it isn't required) and you are responsible for making sure that you are using a compatible assembly.
To silence this NuGet warning (and accepting that there may be issues at run-time when using a package originally authored for .NET Framework), you can add this NoWarn metadata to your package reference:
<PackageReference Include="My.Package" Version="1.2.3" NoWarn="NU1603" />
When I try to install Firebase Messaging Nuget package on the solution it gives me this error -
"Could not install package 'Xamarin.Firebase.Messaging 42.1021.1'. You are trying to install this package into a project that targets 'Xamarin.iOS,Version=v1.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."
And for the android installation it says
"Could not install package 'Xamarin.Firebase.Messaging 42.1021.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.6,Profile=Profile44', 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."
How do I get it to install?
The solution is to use the latest stable Xamarin.Forms and have your project's compileSdkVersion (so Target Framework) set to 7.0 or higher. You will then be able to install newer versions of Android Support and therefore Google Play Services packages.
Happy coding!!
When trying to install the netmq vis nuget, I get the following error:
Could not install package 'AsyncIO 0.1.18'. You are trying to install this package
into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111',
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.
The problem is that netmq depends on AsyncIO. when installing it, nuget find that the assembly is not compatible with .Net 4.5.
so nuget fail in installing AsyncIO, and then failed in installing netmq.
So I downloaded the AsyncIO Source from Github and build it locally with .Net 4.5.
After that and added the dll of AsyncIO built locally as a reference for my project.
Theoretically, NetMQ should be successfully installed with nuget. because I added the needed reference to AsyncIO.
But when trying to reinstall NetMQ, I get the same error:
Could not install package 'AsyncIO 0.1.18'. You are trying to install this package
into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111',
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.
and nuget did not detect that I added 'AsyncIO 0.1.18' in my project.
How to let nuget detect that I added this reference in my project?
Have a look here:
.NET Portable profiles
Profile111 is a combination of:
.NET Framework 4.5
Windows 8.0
Windows Phone 8.1
or in other words:
portable-net45+netcore45+wpa81
So your project into which you are trying to append the NuGet targets Windows Phone 8.1 and other 2 platforms, I mention this one as the most restrictive.
Now let's have a look at the named NuGet package's source:
<ProjectGuid>{3830B7A3-0225-4FDA-B155-E085E183650C}</ProjectGuid>
<OutputType>Library</OutputType>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
What do we have here? We can see that the project is not a PCL. It is targeting full .NET 4.0 framework which is not available on Windows Phone 8.1. And your library does target Windows Phone 8.1. See the problem?
You say that if you compile the AsyncIO targeting .NET 4.5 than you can successfully append it into your project as a reference? That's not altogether true. I mean you can append a reference to it but you cannot use it. You will see that when you try to call something from that reference.
In order to use AsyncIO from you PCL will have to build AsyncIO as a PCL targeting the same or more restrictive set of platforms. Try creating a PCL project targeting Profile111 and try compiling the AsyncIO code with it (just link the original AsyncIO source files (*.cs) into this new AsyncIO_PCL project). If you are lucky enough and the code of AsyncIO is really compatible you will be able to use that library.
Here are your steps:
Create a new project (named AsyncIO_PCL) of type PCL class library.
Pick the Profile111 platform set i.e.
.NET Framework 4.5
Windows 8.0
Windows Phone 8.1
Link all the .cs files from the original AsyncIO project save one (AssemblyInfo.cs) into the new AsyncIO_PCL project.
Set the output assembly name to the same as in original AsyncIO project.
Try building the project.
Your ability to build the AsyncIO as a PCL with the required set of supported platforms depends on AsyncIO code i.e. which API is used inside and if that API is supported by all the three platforms you are targeting.
Try clicking right-button on the project -> Properties. In the "Application" menu check the "Target Framework". It should be set to .NET Framework 4.5
I'm trying to create a nuget package for a PCL library I've made.
This nuget package is intended to be used in a Xamarin Forms application though. So I'm not even sure if the things I've ticked are correct.
I really only care about .NET Framework 4. That is my bare minimum framework. For the rest, I don't care at all and have no idea what I should be targetting.
For what it's worth, I'm using NuGet Package Explorer to create my NuGet nupkg files to manually test them before I publish them to NuGet.
Here's a screenshot of what I was trying, but Xamarin Studio failed to add the nuget package (saying it wasn't the right something-or-rather).
and the error message from Xam Studio:
Adding Foo...
Adding 'Foo 1.3.0' to Core.
Could not install package 'Foo 1.3.0'. You are trying to install this package into a project that targets 'portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10', 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.
For Xamarin.Forms the two profiles that are good ones for your Portable Class Library (PCL) project to use are Profile 78 or Profile 259. Xamarin.Forms can be used in other profiles but if your PCL project targets one of these you should be OK. Your project looks to be targeting Profile 78.
Here are the Xamarin.Forms PCL profiles for reference.
Xamarin.Forms 1.3:
portable-win+net45+wp80+MonoAndroid10+MonoTouch10
Xamarin.Forms 1.4:
portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10
The problem with your NuGet package that it does not indicate that it supports Windows 8 in the PCL. NuGet will look at all the individual frameworks that make up the project's PCL profile (ignoring the Xamarin and Mono ones since they are optional if you do not have them in your NuGet package's PCL profile) and ensure that the NuGet package's PCL profile has a framework which is compatible. If the NuGet PCL does not have a matching framework then NuGet considers it incompatible.
So your NuGet package's portable library folder would need to include win
portable-net4+sl5+wp8+win
Then you can install your NuGet package into your Profile 78 PCL project.