Failed to add MvvmCross 6.0.0 - xamarin

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

Related

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.

Unable to install nuget packages in xamarin android project

I am facing a very strange issue regarding installing NuGet packages in the xamarin android project. When I try to install any NuGet package in xamarin android project getting an error.
Here is the error message I am getting from the NuGet package manager.
?Restoring packages for E:\Projects\Sample\Sample1\Sample2\Smaple3\SampleApp.Android\SampleApp.Android.csproj...
NU1202: Package Microsoft.WindowsAPICodePack.Shell 1.1.0 is not compatible with monoandroid81 (MonoAndroid,Version=v8.1). Package Microsoft.WindowsAPICodePack.Shell 1.1.0 supports: net (.NETFramework,Version=v0.0)
NU1202: Package Microsoft.WindowsAPICodePack.Core 1.1.0 is not compatible with monoandroid81 (MonoAndroid,Version=v8.1). Package Microsoft.WindowsAPICodePack.Core 1.1.0 supports: net (.NETFramework,Version=v0.0)
Package restore failed. Rolling back package changes for 'SampleApp.Android'.
Time Elapsed: 00:00:01.9192186
========== Finished ==========
Installed packages in the Android project:
Remove Microsoft.WindowsAPICodePack from your PCL, since you are having a reference of it in the PCL and then your Android project refers the PCL that works like an indirect reference hence it is causing the issue.
Solution: remove the package from PCL project

NuGet failed installing ImageSharp

I have been trying to install the imagesharp package via NuGet, but I am getting an error from the output window below:
Restoring packages for C:\Users\mycomp\Source\Repos\WebApplication\WebApplication1\WebApplication1.csproj...
Package SixLabors.ImageSharp 1.0.0-beta0001 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package SixLabors.ImageSharp 1.0.0-beta0001 supports:
- netstandard1.1 (.NETStandard,Version=v1.1)
- netstandard1.3 (.NETStandard,Version=v1.3)
Package restore failed. Rolling back package changes for 'WebApplication1'.
Time Elapsed: 00:00:00.9032282
========== Finished ==========
And here from the Error List window:
Error Package restore failed. Rolling back package changes for 'WebApplication1'.
I tried repairing VS 15.4.0 and also updating to VS 15.4.2, but none of it is fixing my issue....any thoughts?
The answer was quite simple in the end. It had nothing to do with the compatibility of the netcoreapp2.0, or either the netstandards1.1/netstandard1.3. That was just a symptom of the real issue. This is how I fixed it:
Tools>Options>NuGet Package Manager>Clear All NuGet Cache/s.
I did get another error while uninstalling from NuGet manager stating access denied to remove the BuildBundlerMinifier package, so I manually deleted it from my .nuget folder, installed SixLabors.ImageSharp package, then reinstalled the BuildBundlerMinifier again, then VOILA! It worked.
Every option that I did try to search for, were either confusing or totally unnecessary.
There is high probability that if you do run into any weird issues like this while installing/uninstalling your NuGet packages, its due to your NuGet cache folder/s.
Seems that you are trying to install ImageSharp in a .Net Core 2.0 project which is not supported. See this line of error message:
"Package SixLabors.ImageSharp 1.0.0-beta0001 is not compatible with netcoreapp2.0"
This looks like a bug in the compatibility check during package installation (not sure if because of an asset that is in an unexpected location or issues with package trimming on .NET Core 2.0 since it depends on prerelease versions of .NET Core packages). When you add the package manually to the csproj file, it should restore and build fine:
<ItemGroup>
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-beta0001" />
</ItemGroup>

Nuget Packager task - dependency is not added

I'm using Visual Studio Team Services to automate the creation of a nuget package. This package has a dependency on another nuget package (Newtonsoft.Json v8.0.3). I have configured a Nuget Packager task as part of the build:
But the generated package doesn't contain the reference to the nuget package:
Running the following script on my local machine to generate the package:
nuget pack myproject.csproj -Symbols -IncludeReferencedProjects -Properties Configuration=Release -OutputDirectory bin/Release
I can see that the dependency is added to the generated package:
What am I missing here? Why the dependencies are not being added to to package that is being generated on the build server?
"IncludeReferencedProjects" is used to add the referenced project to the nuget package, not the referenced nuget packages.
Include referenced projects either as dependencies or as part of the
package. If a referenced project has a corresponding nuspec file that
has the same name as the project, then that referenced project is
added as a dependency. Otherwise, the referenced project is added as
part of the package. Learn more at NuGet.org.
When you create the nuget package for the project which referenced to another nuget package. The nuget package dependency will be added automatically if the nupkg file exists in the packages folder. For your issue, you can add a "NuGet Installer" task in your build definition to restore the nuget package files for your solution. And then when you create the nuget package for your project, the referenced nuget package will be added as dependency.
I have found a solution for my problem, even though I don't understand why the package was not being created properly.
So basically I have 2 builds:
a "generic" build that will compile the entire solution and run unit tests, etc (automatic, triggered on commit)
a build to generate the nuget package (manual)
This problem is on the 2nd build. I was trying to understand what were the differences between creating the package manually on my local machine and creating the package on the build server and I realized that on the build server I was not getting the source code for the solution, only for the project folder and the .nuget folder. Given that I have more than 40 projects in the solution it makes no sense to get the whole source code for the 2nd build, right? But for some reason this is not enough to generate the nuget package properly.
So, the solution to my problem was to get the source code for the following files/folders:
Project folder
.nuget folder (needed when restoring/installing the missing packages)
Solution file (mysolution.sln)

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

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

Resources